[TypeOrmModule] Unable to connect to the database. Retrying (5)... +3004ms
Error: connect ECONNREFUSED 139.59.37.235:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
    --------------------
    at Protocol._enqueue (/var/www/myapp/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/var/www/myapp/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at PoolConnection.connect (/var/www/myapp/node_modules/mysql/lib/Connection.js:116:18)
    at Pool.getConnection (/var/www/myapp/node_modules/mysql/lib/Pool.js:48:16)
    at /var/www/myapp/node_modules/typeorm/driver/mysql/MysqlDriver.js:794:18
    at new Promise (<anonymous>)
    at MysqlDriver.createPool (/var/www/myapp/node_modules/typeorm/driver/mysql/MysqlDriver.js:791:16)
    at MysqlDriver.<anonymous> (/var/www/myapp/node_modules/typeorm/driver/mysql/MysqlDriver.js:278:51)
    at step (/var/www/myapp/node_modules/tslib/tslib.js:136:27)
    at Object.next (/var/www/myapp/node_modules/tslib/tslib.js:117:57)
    at /var/www/myapp/node_modules/tslib/tslib.js:110:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/var/www/myapp/node_modules/tslib/tslib.js:106:16)
    at MysqlDriver.connect (/var/www/myapp/node_modules/typeorm/driver/mysql/MysqlDriver.js:263:24)
    at Connection.<anonymous> (/var/www/myapp/node_modules/typeorm/connection/Connection.js:112:58)
    at step (/var/www/myapp/node_modules/tslib/tslib.js:136:27)
edited by bobbyiliev

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.

×
1 answer

Hello,

As you are connecting from an external server, you need to allow remote connections for your MySQL server.

You can follow the steps on how to do that here:

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

Regards,
Bobby

by Mark Drake
Many websites and applications start off with their web server and database backend hosted on the same machine. With time, though, a setup like this can become cumbersome and difficult to scale. A common solution is to separate these functions by setting up a remote database, allowing the server...
Submit an Answer