Mongodb:Failed to connect - php

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 :)

Related

when I start apache MySQL server, I get error " (HY000/2002): No connection could be made because the target machine actively refused it."

after the start apache server, i could not access PHPMyAdmin. when i try to access i get an error and auto-stop MySQL server.
- mysqli_real_connect(): (HY000/2002): No connection could be made
because the target machine actively refused it.
- Connection for controluser as defined in your configuration failed.
mysqli_real_connect(): (HY000/2002): No connection could be made
because the target machine actively refused it.
- phpMyAdmin tried to connect to the MySQL server, and the server
rejected the connection..
how can i solve this error
Add below line under config.inc.php
$cfg['Servers'][$i]['port'] = 8111;
If you are on Windows os and the above solution does not work, just check if your mysql is running with "netstat -ano" command, if the services are not running just try starting the mysql service.

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

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

Symfony PHP 5.5 : ErrorException: Notice: Memcache::connect(): failed

I am getting error while configuring Memcache with Symfony. Can anyone suggest on this. I have installed Memcache on wamp server using PHP 5.5
ErrorException: Notice: Memcache::connect(): Server localhost (tcp 11211, udp 0) failed with: 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.
(10060)
Your memcached server is not running. You need to start it.
If you're running Ubuntu, it's as simple as sudo service memcached start. For other operating systems, you may want to consult the manual. If you are having problems getting memcached set up, go to Server Fault and ask for help there.

Zend Framework error [database connection]

Today trying to run my project coded under Zend Framework, and connected to a remote database, i got those 2 errors:
PDOException: SQLSTATE[HY000] [2002] 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:\wamp\www\trunk\library\Zend\Db\Adapter\Pdo\Abstract.php on line 129
Zend_Db_Adapter_Exception: SQLSTATE[HY000] [2002] 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:\wamp\www\trunk\library\Zend\Db\Adapter\Pdo\Abstract.php on line 144
Before it was working normally, and i don't know what going on with it today.
It seems it's a connection problem to the database but the question, where the problem come from, from the database server, or my project and where excatly.
It's the first time, i got this error, and i really don't know what that mean.
It sounds like a network problem to me, try a telnet from the app server:
telnet <remote db name/IP> 3306
If that fails, you have a network/firewall problem. Or the DB is is not listening on that port or on the network entirely. Do a netstat on the remote DB to confirm:
Linux
netstat -an | grep LISTENING
Or windows
netstat -an | find "LISTENING"
You should see :3306 if it's listening on the default port.

Categories