首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Prisma绑定无法连接到prisma服务器。请求http://localhost:4466/失败,原因:连接ECONNREFUSED 127.0.0.1:4466

Prisma绑定无法连接到prisma服务器。请求http://localhost:4466/失败,原因:连接ECONNREFUSED 127.0.0.1:4466
EN

Stack Overflow用户
提问于 2018-05-16 17:57:43
回答 2查看 4.4K关注 0票数 0

我在经营两个独立的码头服务。一个用于我的GraphQL服务器,另一个是连接到本地Postgres数据库的prisma服务。我能够在http://localhost:4466中直接运行prisma部署并测试它。但是当我试图在http://localhost:8080中使用我的应用程序的http://localhost:8080服务器进行查询时,它会给出以下响应。

代码语言:javascript
复制
{
  "data": null,
  "errors": [
    {
      "message": "request to http://localhost:4466/ failed, reason: connect ECONNREFUSED 127.0.0.1:4466",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "feed"
      ]
    }
  ]
}

这是堆栈跟踪。

代码语言:javascript
复制
graphql-server_1  | [Network error]: FetchError: request to http://localhost:4466/ failed, reason: connect ECONNREFUSED 127.0.0.1:4466
graphql-server_1  | Error: request to http://localhost:4466/ failed, reason: connect ECONNREFUSED 127.0.0.1:4466
graphql-server_1  |     at new CombinedError (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/errors.js:83:28)
graphql-server_1  |     at Object.checkResultAndHandleErrors (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/errors.js:101:15)
graphql-server_1  |     at CheckResultAndHandleErrors.transformResult (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/transforms/CheckResultAndHandleErrors.js:10:25)
graphql-server_1  |     at /usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/transforms/transforms.js:19:54
graphql-server_1  |     at Array.reduce (<anonymous>)
graphql-server_1  |     at applyResultTransforms (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/transforms/transforms.js:18:23)
graphql-server_1  |     at /usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:82:50
graphql-server_1  |     at step (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:32:23)
graphql-server_1  |     at Object.next (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:13:53)
graphql-server_1  |     at fulfilled (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:4:58)

我就是这样创建绑定的

代码语言:javascript
复制
const server = new GraphQLServer({
  typeDefs: './src/schema.graphql',
  resolvers,
  context: req => ({
    ...req,
    db: new Prisma({
      typeDefs: './src/generated/prisma.graphql',
      endpoint: 'http://localhost:4466',
      secret: 'my-secret',
      debug: true,
    })
  })
});

我不知道问题出在哪里。

完整的代码可以在这里找到:https://github.com/dhanushuUzumaki/Journal/tree/feature/setup

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-05-17 17:23:55

从prisma论坛那里得到了解决这个问题的帮助。

在容器中使用localhost指向容器本身,而不是运行容器的主机。因此,为了连接到Prisma实例,您必须使用内部服务名称,它解析为相应的Prisma容器。

代码语言:javascript
复制
...
    db: new Prisma({
      typeDefs: './src/generated/prisma.graphql',
      endpoint: 'http://prisma:4466',
      secret: 'my-secret',
      debug: true,
    })
...

Prisma论坛- ECONNREFUSED无法通过绑定连接到prisma服务

票数 6
EN

Stack Overflow用户

发布于 2018-09-21 13:03:29

这发生在我在windows上使用Docker时,必须将端点从使用本地主机更改为prisma.yml中的prisma.yml默认ip

代码语言:javascript
复制
endpoint: http://192.168.99.100:4466
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50377318

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档