"Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: /tmp/mongodb-27017.sock:0: Connection refused''"
<p>I have the following code:</p>

<pre><code>$this-&gt;connection = new MongoClient($uri, $options);
$this-&gt;database = $database;
</code></pre>

<p>However, at line <code>$this-&gt;connection</code> I get:</p>

<pre><code>Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: /tmp/mongodb-27017.sock:0: Connection refused' in...
</code></pre>

<p>If I output the following:</p>

<pre><code>var_dump($uri, $options); exit;
</code></pre>

<p>I get:</p>

<pre><code>string(33) "mongodb:///tmp/mongodb-27017.sock" array(1) { ["connect"]=&gt; bool(true) } 
</code></pre>

<p>This is in my dev environment, I'm not using any username/password for Mongo as I can login to the Mongo shell with <code>mongo reputation</code> alone. From there I can view collection and documents.</p>

<p>Originally I was getting Permissions denied, but I changed the permissions of my dev /tmp/mongodb-27017.sock to 777. Now I get "connection refused".</p>

<p>Anyway below is the file from my <code>ll /tmp/</code> dir:</p>

<pre><code>srwxrwxrwx  1 mongodb mongodb     0 Jan 28 07:47 mongodb-27017.sock=
</code></pre>

<p>Anyone know what the issue is, or how I can debug further? Thanks</p>