title: Cannot connect to mongoDB null.<anonymous>
body: <p>So node.js keeps throwing:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>Error: failed to connect to [domainName.io:27017]
      at null.&lt;anonymous&gt; (/var/www/domainName.io/public_html/programming/projects/timeTracker/node_modules/mongojs/node_modules/mongodb/lib/mongodb/connection/server.js:555:74)
      at emit (events.js:106:17)
      at null.&lt;anonymous&gt; (/var/www/domainName.io/public_html/programming/projects/timeTracker/node_modules/mongojs/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:156:15)
      at emit (events.js:98:17)
      at Socket.&lt;anonymous&gt; (/var/www/domainName.io/public_html/programming/projects/timeTracker/node_modules/mongojs/node_modules/mongodb/lib/mongodb/connection/connection.js:534:10)
      at Socket.emit (events.js:95:17)
      at net.js:441:14
      at process._tickCallback (node.js:442:13</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am using the following server.js file to spawn http server and connect to mongoDB</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> var
    2     http = require("http"),
    3     mongojs = require("mongojs");
    4
    5                 var
    6     uri ="mongodb://userName:password@domainName.io/mydb",
    7     db = mongojs.connect(uri, ["activities"]);
    8
    9 var
   10     server = http.createServer(requestHandler);
   11
   12
   13 function requestHandler(request, response) {
   14         response.writeHead(200, {"Content-Type": "text/html"});
   15         db.activities.find({"name":"mongoDB"}, function(err, records) {
   16             if(err) {
   17                 console.log("There was an error executing the database quer    y.");
   18                 response.end();
   19                 return;
   20             }
   21
   22         var
   23             html = '&lt;h2&gt; Activities &lt;/h2&gt;',
   24             i = records.length;
   25
   26         while (i--){
   27                 html += '&lt;p&gt;&lt;b&gt;Name:&lt;/b&gt; '
   28                      + rescords[i].name
   29                      + ' &lt;br /&gt;&lt;b&gt;Time:&lt;/b&gt; '
   30                      + records[i].time;
   31         }
   32         response.write(html);
   33         response.end();
   34 });
   35 };
   36
   37 server.listen(8888);</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is my first attempt at running mongoDB with nodeJS so not too sure how to trouble shoot this. I am using the default mongodb port 27017 and created user I believe properly:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&gt; use mydb
  &gt;db.createUser({user:"userName",pwd:"password"...})</code></pre>
  </div>
  </div>
  </p>
  
  <p>any help or direction to go forht and try to debug would be awesome.</p>