title: API Pod failed to connect to mongo pod in the same kubernetes cluster
body: <p>I was running a nodejs api as a pod on a google compute engine managed by kubernetes.  The API was connecting to database well but then it failed suddenly showing this error:</p>
  
  <pre><code>listening to http server on 0.0.0.0:8080...
  
  events.js:160
        throw er; // Unhandled 'error' event
        ^
  MongoError: failed to connect to server [mongo:27017] on first connect [MongoError: getaddrinfo ENOTFOUND mongo mongo:27017]
      at Pool.&lt;anonymous&gt; (/usr/src/app/node_modules/mongodb-core/lib/topologies/server.js:328:35)
      at emitOne (events.js:96:13)
      at Pool.emit (events.js:188:7)
      at Connection.&lt;anonymous&gt; (/usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:274:12)
      at Connection.g (events.js:292:16)
      at emitTwo (events.js:106:13)
      at Connection.emit (events.js:191:7)
      at Socket.&lt;anonymous&gt; (/usr/src/app/node_modules/mongodb-core/lib/connection/connection.js:177:49)
      at Socket.g (events.js:292:16)
      at emitOne (events.js:96:13)
      at Socket.emit (events.js:188:7)
      at connectErrorNT (net.js:1021:8)
      at _combinedTickCallback (internal/process/next_tick.js:80:11)
      at process._tickDomainCallback (internal/process/next_tick.js:128:9)
  </code></pre>
  
  <p>I tried to restart the prods, to delete and re-create containers but no success? </p>
  
  <p>this is how I connect to database:</p>
  
  <pre><code>mongoose.connect(process.env.MONGO_DEV_URL || process.env.MONGODB_URI || 'mongodb://mongo:27017:yaxiDb/yaxiDb', { useMongoClient: true });
  </code></pre>
  
  <p>How can I debug this, where could be the problem?</p>