当我尝试打开postgraphile UI时,它不起作用。我得到了以下错误。
生成初始架构时发生严重错误。退出是因为没有设置
retryOnInitFail。
错误:连接意外终止
在连接处。(D:\cars-assignment\node_modules\pg\lib\client.js:132:73)
在Object.onceWrapper (events.js:421:28)
在Connection.emit (events.js:315:20)
在插座上。(D:\cars-assignment\node_modules\pg\lib\connection.js:108:12)
在Socket.emit (events.js:327:22)
在endReadableNT (_stream_readable.js:1201:12)
在processTicksAndRejections (内部/进程/任务_Quees.js:84:21)
我使用以下命令npx postgraphile -c postgres://username:SECRET@localhost:5000/db
如何解决这一问题?
发布于 2021-06-03 01:18:29
我认为错误输出比@deluxan显示的更多。至少对我来说是这样。我认为问题在于postgraphile忽略了连接字符串中指定的端口。首先,我让PostgreSQL运行在端口5555上的一个Docker容器中。
17502bafdf52 exspda_postgis "docker-entrypoint.s…" 2 months ago Up 5 minutes 0.0.0.0:5555->5432/tcp exspda_postgis然后当我试图通过Docker运行Postgraphile时..。
$ docker run --init -p 5000:5000 graphile/postgraphile --connection postgres://hippo:mypassword@localhost:5555/first_geo --schema public --watch...the的全部输出是:
PostGraphile v4.12.1 server listening on port 5000
‣ GraphQL API: http://0.0.0.0:5000/graphql
‣ GraphiQL GUI/IDE: http://0.0.0.0:5000/graphiql (RECOMMENDATION: add '--enhance-graphiql')
‣ Postgres connection: postgres://hippo:[SECRET]@localhost/first_geo (watching)
‣ Postgres schema(s): public
‣ Documentation: https://graphile.org/postgraphile/introduction/
‣ Node.js version: v12.22.1 on linux x64
‣ Join Storyscript in supporting PostGraphile development: https://graphile.org/sponsor/
* * *
A serious error occurred when building the initial schema. Exiting because `retryOnInitFail` is not set. Error details:
Error: connect ECONNREFUSED 127.0.0.1:5432
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)输出Postgres connection: postgres://hippo:[SECRET]@localhost/first_geo不包括连接字符串中指定的端口。实际的错误似乎也表明我指定的端口没有被使用:Error: connect ECONNREFUSED 127.0.0.1:5432。当我指定5555时,它正在尝试使用端口5432。我想这和“豪华体验”是一样的。端口5432是硬编码的明信片吗?如何固定以识别用户提供的连接字符串中指定的端口?
请注意,我是全新的邮政,所以我的道歉愚蠢(即,对其他人显而易见)的疏忽和错误!
发布于 2021-04-01 08:31:42
这是Node和Postgres之间的连接错误。尝试直接连接pg模块;它应该以同样的方式失败,您可以从那里继续调试:
const { Pool } = require('pg');
const pool = new Pool({
connectionString: "postgres://username:SECRET@localhost:5000/db"
});
async function main() {
await pool.query('select 1');
pool.end();
console.log('All good.');
}
main().catch(e => {
console.error(e);
process.exit(1);
});我怀疑:5000是错误的,因为这是PostGraphile默认尝试侦听的端口,而postgres默认使用:5432。
https://stackoverflow.com/questions/66889972
复制相似问题