我有一个节点服务器托管在EC2实例上,它试图连接到运行在同一实例上的Postgres。当我启动服务器,我得到一个ECONNREFUSED错误的分贝:无法连接到EC2上的Postgres:ECONNREFUSED
Unable to connect to the database: SequelizeConnectionRefusedError: connect ECONNREFUSED x.x.x.x:5432
我使用Sequelize ORM包从NPM:
import Sequelize from 'sequelize';
const db = new Sequelize('postgres://[email protected]/unloadx' {dialect: 'postgres'});
的Postgres是在实例上运行,并且我有端口5432在我的入站安全规则中打开。我可以证实,Postgres的与ps aux | grep postgres
这说明相关的流程多Postgres的运行,并netstat -anp --tcp
确认Postgres的似乎是在端口上侦听:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp6 0 0 ::1:5432 :::* LISTEN -
但当我扫描端口nmap x.x.x.x -p 5432
它显示端口状态关闭了。根据nmap,这意味着该端口是可访问的,但没有监听应用程序的应用程序能够响应数据包。
感谢获得连接工作的任何帮助。
这是它,谢谢正确已经设置你的Postgres服务器。 FWIW'localhost'工作,但不是127.0.0.1 – aeb0