首页 > 解决方案 > Postgraphile error while trying to open UI

问题描述

When I try to open postgraphile UI it's not working. I'm getting the following error.

A serious error occurred when building the initial schema. Exiting because retryOnInitFail is not set.

Error: Connection terminated unexpectedly
at Connection. (D:\cars-assignment\node_modules\pg\lib\client.js:132:73)
at Object.onceWrapper (events.js:421:28)
at Connection.emit (events.js:315:20)
at Socket. (D:\cars-assignment\node_modules\pg\lib\connection.js:108:12)
at Socket.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)

I'm using the following command npx postgraphile -c postgres://username:SECRET@localhost:5000/db

How to resolve this issue?

标签: graphqlnestjspostgraphile

解决方案


我认为错误输出比@deluxan 显示的更多。至少对我来说有。我认为问题在于 postgraphile 忽略了连接字符串中指定的端口。首先,我在端口 5555 上公开的 Docker 容器中运行 PostgreSQL。

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

...完整的输出是:

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。我怀疑这与@deluxan 经历的相同。端口 5432 是否在 postgraphile 中硬编码?如何修复识别用户提供的连接字符串中指定的端口?

请注意,我是 Postgraphile 的新手,所以我为愚蠢的(即对其他人来说显而易见的)疏忽和错误道歉!


推荐阅读