Error: connect ECONNREFUSED & Open MySQL Port (remote)

Error:

node:events:505
throw er; // Unhandled ‘error’ event
^

Error: connect ECONNREFUSED your-ip:3306
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)
Emitted ‘error’ event on Connection instance at:
at Connection._notifyError (\node_modules\mysql2\lib\connection.js:236:12)
at Connection._handleFatalError (\node_modules\mysql2\lib\connection.js:167:10)
at Connection._handleNetworkError (\node_modules\mysql2\lib\connection.js:180:10)
at Socket.emit (node:events:527:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -4078,
code: ‘ECONNREFUSED’,
syscall: ‘connect’,
address: ‘your-ip’,
port: 3306,
fatal: true
}

 

Solution:

1- open configuration file /etc/mysql/my.cnf (ex: vim my.cnf)

2- add line

[mysqld]

bind-address = 0.0.0.0and save the file

3- restart mysql service: service mysql restart

4- verify the server listening: sudo netstat -plutn | grep 3306

Leave a Reply

Your email address will not be published. Required fields are marked *