com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting to connect
This error could be due to multiple reason. You can debug it by trying the following ways:
- Check if mongod is running
check if the mongo process is actually running or not using "ps aux | grep mongo" or "sudo service mongod status". If the process isn't running start it. - Check on which port the process is running.
run command "sudo netstat -tlupn" and check its running on which port. Generally the port is 27017 but it could be some other port as well and you might be connecting to wrong port from application/client. - Try doing a "telnet" to mongo from the application server or the client if you are able to connect to mongo shell.
"sudo telnet <mongo-server-ip> port" == "telnet 192.168.1.2 27017" - Check if mongo process is bind to which IP. Is it bind to 0.0.0.0 (anywhere) or to 127.0.0.1 (localhost).
"sudo netstat -tlupn | grep 27017" - There could be a possibility if you have started a mongo server from the data of a replicaset and your standalone replicaset hasn't been initialised, in this case as well you will get this error.
In that case you can delete local db and initiate the replicaset to make it standalone primary.
>use local
> db.dropDatabase();
{ "dropped" : "local", "ok" : 1 }
> rs.initiate()
>myrepl:PRMIARY
Kadak Info Bhawa
ReplyDelete