Question

why TypeOrm is not connect to MySQL in digital ocean server

[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)
Subscribe
Share

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

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.

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