ECONNREFUSED Node.js服务器无法连接到AWS mysql实例

时间:2019-04-27 20:17:05

标签: mysql node.js amazon-web-services network-programming

我正在尝试连接到AWS托管的mysql数据库。我与Mysql工作台连接没有问题,并且为了测试可以允许所有流量进入数据库,但是我仍然无法与服务器连接。

我用以下代码重现了我的错误:

var mysql = require('mysql');

var db_config = require('../config/database')

var pool = mysql.createConnection(db_config);

pool.query("SELECT * FROM users", function (error, results, fields) {
  if (error) {
    throw error;
}
})

Error: connect ECONNREFUSED 127.0.0.1:3306
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
--------------------
at Protocol._enqueue (/Users/Amin/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/Users/Amin/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/Users/Amin/node_modules/mysql/lib/Connection.js:118:18)
at Connection._implyConnect (/Users/Amin/node_modules/mysql/lib/Connection.js:453:10)
at Connection.query (/Users/Amin/node_modules/mysql/lib/Connection.js:198:8)
at Object.<anonymous> (/Users/Amin/Projects/Relation-Quest/backend/tests/db-test.js:7:6)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)

有任何调试思路吗?

0 个答案:

没有答案