title: node can't connect to Mongo -- Error: getaddrinfo ENOTFOUND undefined undefined:27017
body: <p>When I try to start my express server with <code>node index.js</code> I get the following error message:</p>
  
  <pre><code>*path/to/project*/node_modules/mongodb/lib/server.js:242
          process.nextTick(function() { throw err; })
                                        ^
  Error: getaddrinfo ENOTFOUND undefined undefined:27017
      at errnoException (dns.js:26:10)
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)
  </code></pre>
  
  <p>There are many questions on Stack Overflow with similar error messages but they are mostly due to either not running mongod or typos.</p>
  
  <p>I am running mongod, I can connect to mongo via the terminal. I changed some code and hit some errors, but then started fresh from working code. The current code worked to connect to MongoDB before (and production version works with the same code).</p>
  
  <p>I can also run an express server and connect to MongoDB on the same machine with different node projects with similar setups.</p>