<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>The MongoConnectionException class</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="class.mongocursortimeoutexception.html">MongoCursorTimeoutException</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.mongogridfsexception.html">MongoGridFSException</a></div> <div class="up"><a href="mongo.exceptions.html">Exceptions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="class.mongoconnectionexception" class="reference"> <h1 class="title">The MongoConnectionException class</h1> <div class="partintro"><p class="verinfo">(PECL mongo >= 1.0.0)</p> <div class="section" id="mongoconnectionexception.intro"> <h2 class="title">Introduction</h2> <p class="para"> Thrown when the driver fails to connect to the database. </p> <p class="para"> There are a number of possible error messages to help you diagnose the connection problem. These are: </p> <ul class="itemizedlist"> <li class="listitem"> <p class="para"> <em>No candidate servers found</em> </p> <p class="para"> Thrown when the driver cannot establish a connection to MongoDB (fulfilling the ReadPreferences, if specified). </p> </li> <li class="listitem"> <p class="para"> <em>No server name given.</em> </p> <p class="para"> This error occurs if you pass in "" as the server name, probably because of an typo with string interpolation, e.g., "$servr" instead of "$server". </p> </li> <li class="listitem"> <p class="para"> <em> failed to get host [hostname] or port [portnum] from [server]. </em> </p> <p class="para"> This indicated that the server string was malformed. "[hostname]" and "[portnum]" will be as much as the driver could dicipher of it. </p> </li> <li class="listitem"> <p class="para"> <em>Operation in progress</em> </p> <p class="para"> Connecting to the database timed out. </p> </li> <li class="listitem"> <p class="para"> <em>Transport endpoint is not connected</em> </p> <p class="para"> Generally means that the connection string isn't correct, the driver couldn't even find the database server. </p> </li> <li class="listitem"> <p class="para"> <em>couldn't determine master</em> </p> <p class="para"> No server in a replica set connection was identified as the primary. </p> </li> <li class="listitem"> <p class="para"> <em>couldn't get host info for [server]</em> </p> <p class="para"> This indicated that DNS could not resolve the server address you gave. This could easily be caused by a typo, for example, "server" instead of "$server". </p> </li> <li class="listitem"> <p class="para"> <em>Invalid Argument</em> </p> <p class="para"> This can be caused by attempting to connect to a machine that is up but that the database isn't actually running on. Make sure that you've started the database server before connecting. </p> </li> <li class="listitem"> <p class="para"> <em>Permission denied</em> </p> <p class="para"> This means that the socket could not be opened due to permissions issues. On Red Hat variants, this can be caused by a default setting that does not allow Apache to create network connections. You can override this setting by running: <div class="example-contents"> <div class="cdata"><pre> $ /usr/sbin/setsebool -P httpd_can_network_connect 1 </pre></div> </div> then restarting Apache. </p> </li> </ul> <p class="para"> If the error message is not listed above, it is probably an error from the C socket, and you can search the web for its usual cause. </p> </div> <div class="section" id="mongoconnectionexception.synopsis"> <h2 class="title">Class synopsis</h2> <div class="classsynopsis"> <div class="ooclass"></div> <div class="classsynopsisinfo"> <span class="ooclass"> <strong class="classname">MongoConnectionException</strong> </span> <span class="ooclass"> <span class="modifier">extends</span> <a href="class.mongoexception.html" class="classname">MongoException</a> </span> {</div> }</div> </div> </div> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="class.mongocursortimeoutexception.html">MongoCursorTimeoutException</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.mongogridfsexception.html">MongoGridFSException</a></div> <div class="up"><a href="mongo.exceptions.html">Exceptions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>