title: Losing Database Connection on Amazon Ec2 Server
body: <p>For the last few months I am facing an issue, I deployed my application on amazon ec2 server but at least 10 to 30 times a day I get these errors.</p>
  
  <pre><code>1) Error: connect ETIMEDOUT
      at errnoException (net.js:904:11)
      at Object.afterConnect [as oncomplete] (net.js:895:19)
  
  2) Error: getaddrinfo ENOTFOUND
       at errnoException (dns.js:37:11)
       at Object.onanswer [as oncomplete] (dns.js:124:16)
       --------------------
      at Handshake.Sequence                                            (/var/app/current/node_modules/mysql/lib/protocol/sequences/Sequence.js:15:20)
  at new Handshake (/var/app/current/node_modules/mysql/lib/protocol/sequences/Handshake.js:9:12)
  at Protocol.handshake (/var/app/current/node_modules/mysql/lib/protocol/Protocol.js:42:50)
  at Connection.connect (/var/app/current/node_modules/mysql/lib/Connection.js:72:18)
  at module.exports.connect (/var/app/current/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:276:16)
  at Object.pool.Pooling.Pool.create (/var/app/current/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:125:19)
  at createResource (/var/app/current/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:258:13)
  at dispense (/var/app/current/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:250:9)
  at Object.me.acquire (/var/app/current/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:316:5)
  at module.exports.enqueue (/var/app/current/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:320:19)
  
  3) TypeError: Uncaught, unspecified "error" event.
  at TypeError (&lt;anonymous&gt;)
  at EventEmitter.emit (events.js:74:15)
  at Handshake._callback (/var/app/current/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:286:19)
  at Handshake.Sequence.end (/var/app/current/node_modules/mysql/lib/protocol/sequences/Sequence.js:75:24)
  at Protocol.handleNetworkError (/var/app/current/node_modules/mysql/lib/protocol/Protocol.js:238:14)
  at Connection._handleNetworkError (/var/app/current/node_modules/mysql/lib/Connection.js:155:18)
  at Socket.EventEmitter.emit (events.js:117:20)
  at net.js:830:16
  at process._tickDomainCallback (node.js:459:13)
  </code></pre>
  
  <p>Any idea how to fix these issues ?</p>
  
  <p>Before posting here I posted similar question on github as well and I got unsatisfactory answer that this is an amazon issue and many of the people are facing it.</p>
  
  <p>So guys any suggestion or solution regarding this issue ?</p>