MongoConnectionException - No candidate servers found MongoConnectionException - No candidate servers found php php

MongoConnectionException - No candidate servers found


I would suggest you add logging to find out what is happening. The Mongo driver (since version 1.3) provides extensive logging to debug connection issues. There is an article at http://derickrethans.nl/mongodb-debugging.html to explain how to turn it on. If from the log info it is not clear what happens, update your question with the log, so that I can update my answer.

From the posted log I can see that your client can not connect to any of the seeds from your connection string. If your machine/client can't connect, you can't talk to MongoDB of course. In this case, there can be a few possibilities:

  • The driver can't convert the names to IP addresses. In that case, you need to fix your DNS setup, or add all hosts to /etc/hosts
  • You really can't connect to them, this could be a firewall in the way.
  • There are some issues with that in the 1.2 series of the driver, so if you're not using 1.3.4 or higher yet, I'd suggest you upgrade. It should be a much smoother experience.
  • Remember that you need a majority of your nodes up in order to be able to write. If you don't have that, then you will get the "No candidate servers" error.