Question

Cannot connect to database with node.js

Urgent need please help me out with the issue I am getting the below error when trying to connect my node.js with database

I am getting the below error when trying to connect my node.js with database, its working fine with the local database but when connecting to digital ocean database getting the below error can anyone please help me out…

Unable to connect to the database: ConnectionError [SequelizeConnectionError]: connect ETIMEDOUT
    at ConnectionManager.connect (C:\Users\Gorthy\Desktop\log-reader\log-reader\node_modules\sequelize\lib\dialects\mysql\connection-manager.js:126:17)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  parent: Error: connect ETIMEDOUT
      at Connection._handleTimeoutError (C:\Users\Gorthy\Desktop\log-reader\log-reader\node_modules\mysql2\lib\connection.js:178:17)
      at listOnTimeout (internal/timers.js:549:17)
      at processTimers (internal/timers.js:492:7) {
    errorno: 'ETIMEDOUT',
    code: 'ETIMEDOUT',
    syscall: 'connect',
    fatal: true
  },
  original: Error: connect ETIMEDOUT
      at Connection._handleTimeoutError (C:\Users\Gorthy\Desktop\log-reader\log-reader\node_modules\mysql2\lib\connection.js:178:17)
      at listOnTimeout (internal/timers.js:549:17)
      at processTimers (internal/timers.js:492:7) {
    errorno: 'ETIMEDOUT',
    code: 'ETIMEDOUT',
    syscall: 'connect',
    fatal: true
  }
}
(node:13788) UnhandledPromiseRejectionWarning: SequelizeConnectionError: connect ETIMEDOUT
    at ConnectionManager.connect (C:\Users\Gorthy\Desktop\log-reader\log-reader\node_modules\sequelize\lib\dialects\mysql\connection-manager.js:126:17)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:13788) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)        
(node:13788) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there @qnptechnologies,

Are you using a DigitalOcean Managed Database cluster or did you install an SQL server on a Droplet?

If you are using a Managed Database, I would suggest making sure that you are using the correct custom Port and also that you’ve added your IP address to the trusted list so that you could connect to the database.

If you are using an SQL server installed on a Droplet, then make sure that you’ve allowed external connections as described here:

https://www.digitalocean.com/community/tutorials/how-to-allow-remote-access-to-mysql

Hope that this helps! Regards, Bobby