why TypeOrm is not connect to MySQL in digital ocean server

[TypeOrmModule] Unable to connect to the database. Retrying (5)... +3004ms
Error: connect ECONNREFUSED
    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 (/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)

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


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:

Regards, Bobby