MongoDB PHP Failed to connect to: Timed out after 0 ms - php

I use MongoDB shardings. normally, it works well, but sometimes, failed to connect, and the message shows the error Timed out after 0ms.
Failed to connect to: 192.168.1.10:35050: Timed out after 0 ms
PHP : 5.3.25
MongoDB: 2.4.7

Related

MongoDB + PHP: Error "Failed to connect to 127.0.0.1:27017"

I have running a EC2 instance with MongoDB and some .php files to deploy a little webpage.
PHP shows productos taken from MongoDB.
<?php
include_once("header.php");
require 'vendor/autoload.php';
$uri="mongodb://localhost";
$client=new MongoDB\Client($uri);
$collection = $client->tienda->categorias->find();
$categorias=array();
When I created DB it was no problem. After a new login to EC2 webpage doesn't show anything from DB.
When I try to check DB this error returns:
> use tienda
> show collections
2020-05-13T17:29:29.612+0000 I NETWORK [thread1] trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2020-05-13T17:29:29.612+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2020-05-13T17:29:29.612+0000 I NETWORK [thread1] reconnect 127.0.0.1:27017 (127.0.0.1) failed failed
2020-05-13T17:29:29.612+0000 E QUERY [thread1] Error: socket exception [CONNECT_ERROR] for couldn't connect to server 127.0.0.1:27017, connection attempt failed :
runClientFunctionWithRetries#src/mongo/shell/session.js:346:31
runCommand#src/mongo/shell/session.js:412:25
DB.prototype._runCommandImpl#src/mongo/shell/db.js:145:16
DB.prototype.runCommand#src/mongo/shell/db.js:161:20
DB.prototype._getCollectionInfosCommand#src/mongo/shell/db.js:930:19
DB.prototype.getCollectionInfos#src/mongo/shell/db.js:953:19
DB.prototype.getCollectionNames#src/mongo/shell/db.js:964:16
shellHelper.show#src/mongo/shell/utils.js:809:9
shellHelper#src/mongo/shell/utils.js:706:15
#(shellhelp2):1:1
2020-05-13T17:24:05.117+0000 I NETWORK [thread1] trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2020-05-13T17:24:05.117+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2020-05-13T17:24:05.117+0000 I NETWORK [thread1] reconnect 127.0.0.1:27017 (127.0.0.1) failed failed
After some google hours the only way I found to keep DB working is running on a new tab
$ mongod
Once I close this tab, DB stops to work and webpay stops to display products.
Is there any way to fix this?
I'm new to MongoDB btw.
You can run the MongoDB process as a daemon
mongod --fork --logpath /var/log/mongodb/mongod.log
Where logpath is where logs will be saved.
Documentation:
https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/

Mongo connect failing

I'm running mongodb on my local mac which was running fine in combination with MAMP. However it's not working, and when I call it in terminal, I now get this:
$ mongo
MongoDB shell version: 3.2.11
connecting to: test
2017-02-23T18:43:39.841+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2017-02-23T18:43:39.842+0000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:229:14
#(connect):1:6
exception: connect failed
Any ideas?
Thanks!
mongo is off, you can run mongod to see where the initialization fails

Mongodb:Failed to connect

I am new to MongoDB.I installed mongodb and used with Laravel framework.Its had been worked for a long time without any issues.But currently while i try to acess my website it shows:
Failed to connect to: localhost:27017: Connection refused
when i try to acces mongodb via command line,it shows:
warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146 exception: connect failed
when i try to access it via rock tool,it shows:
Unable to connect MongoDB, please check your configurations. MongoDB said:Failed to connect to: 127.0.0.1:27017: Connection refused.
what i will do? I can't figure what's wrong from my part since its working after the past months.I do nothing since the last days.Thanks in advance..
After a short break, I can find out the solution.
The origin of that issue is the unexpected shutdown of the system.So i run the below code in command prompt:
sudo rm /var/lib/mongodb/mongod.lock
mongod --repair
sudo service mongodb start
then after the above code run, its working fine :)

Failed to connect to: localhost:27017: Connection refused

I have installed MongoDB in xampp on Ubuntu using Laravel 5.1. But I always get this error
MongoConnectionException in TestController.php line 19: Failed to
connect to: localhost:27017: Connection refused
Nor I'm able
I have gone through a lot of questions, but all proved to be trivial solution.
Please help me with this as I'm stuck on it.
I think that first thing to do is to ssh on that server and check that mongod process is alive, then try open mongo shell using command - mongo . If all works try telnet on this server and port from your machine ,if there is no errors , read mongo logs

PHP timeout during simple connection to MySQL - on win2k8 64bit IIS 7 / FastCGI php - new install

I installed PHP/FastCGI and Mysql on w2k8 64bit IIS7.
PHPinfo() loads fine, and MySQL extension is properly installed. PHP displays echo commands.
MySQL also works fine through the MySQL Command Line Client. I can create DBs, tables and users.
However MySQL does not respond and the PHP script times out when simply connecting with mysql_connect("localhost","user goes here","pass goes here");
I miss win2k3.
Any ideas?
PHP Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\inetpub\wwwroot\test.php on line 9 PHP Warning: mysql_connect() [function.mysql-connect]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\inetpub\wwwroot\test.php on line 9 PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\inetpub\wwwroot\test.php on line 12
Can you try 127.0.0.1 instead of localhost?
Seems to be a right-out bug.

Categories