Wednesday 27 September 2017

com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting to connect

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:

  1. 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.
  2. 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.
  3. 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"
  4. 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"
  5. 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

1 comments:

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel