【发布时间】:2018-07-25 02:57:00
【问题描述】:
我正在尝试在 aws 上在线上传节点应用程序。
当我在本地启动应用程序时,它工作得非常好,因为我的应用程序可以访问 postgres。
但是,当我上传我的服务器时,它就无法连接到数据库。
我的应用使用 loopback.io。
这是 server/config.json :
{
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 3000,
"remoting": {
"context": false,
"rest": {
"handleErrors": false,
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false
},
"legacyExplorer": false,
"logoutSessionsOnSensitiveChanges": true
}
这里是/server/datasources.json
{
"db": {
"name": "db",
"connector": "memory"
},
"postgres": {
"host": "localhost",
"port": 5432,
"url": "",
"database": "postgres",
"password": "postgresseason",
"name": "postgres",
"user": "postgres",
"connector": "postgresql"
}
}
我已经进行了研究,我认为我必须更改一个网址,以便它不会尝试寻找“本地”方式,但无法使其工作。
我尝试使用 url postgress://postgres:postgresseason@db:5432/postgres 没有成功。
我得到的错误是:
Web server listening at: http://0.0.0.0:8080
Browse your REST API at http://0.0.0.0:8080/explorer
Connection fails: Error: getaddrinfo ENOTFOUND db db:5432
It will be retried for the next request.
或者:
Web server listening at: http://0.0.0.0:3000
Browse your REST API at http://0.0.0.0:3000/explorer
Connection fails: Error: connect ECONNREFUSED 127.0.0.1:5432
It will be retried for the next request.
任何帮助如何使它工作? 谢谢
【问题讨论】:
标签: node.js postgresql amazon-web-services