question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

request to url failed, reason: connect ECONNR EFUSED 127.0.0.1:8001

See original GitHub issue

Describe the bug

To Reproduce Steps to reproduce the behavior:

  1. Start a blank Svelte project
  2. Install required dependencies:
npm install @graphql-codegen/cli -D

npm i @graphql-codegen/typescript @graphql-code
gen/typescript-operations -D

npm i @graphql-codegen/typescript-urql @graphql
-codegen/urql-introspection @graphql-codegen/urql-svelte-operations-stor
e -D

npm i @urql/svelte urql graphql
  1. Create a codegen.yml config:
overwrite: true
schema: "http://localhost:8001/"
documents: "src/**/*.graphql"
config:
  withHooks: false
generates:
  src/graphql/generated/graphql.ts:
    plugins:
      - "typescript"
      - "typescript-operations"
      - "typescript-urql"
      - "urql-svelte-operations-store"
  1. Create a script in package.json for codegen:
{
...
"scripts": {
  ...
  "generate": "graphql-codegen --config codegen.yml"
  ...
}
...
}
  1. Have a backend API running on localhost:8001 image

  2. Run npm run generate

  3. Get the error:

> generate
> graphql-codegen --config codegen.yml

  βœ” Parse configuration
  ❯ Generate outputs
    ❯ Generate src/graphql/generated/graphql.ts
      βœ– Load GraphQL schemas
        β†’ Failed to load schema
        Load GraphQL documents
        Generate


 Found 1 error

  βœ– src/graphql/generated/graphql.ts
    Failed to load schema from http://localhost:8001/:

        request to http://localhost:8001/ failed, reason: connect ECONNR
EFUSED 127.0.0.1:8001
        FetchError: request to http://localhost:8001/ failed, reason: co
nnect ECONNREFUSED 127.0.0.1:8001
    at ClientRequest.<anonymous> (/workspace/node_modules/node-fetch/lib
/index.js:1491:11)
    at ClientRequest.emit (node:events:390:28)
    at Socket.socketErrorListener (node:_http_client:447:9)
    at Socket.emit (node:events:390:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:2
1)

        GraphQL Code Generator supports:
          - ES Modules and CommonJS exports (export as default or named 
export "schema")
          - Introspection JSON File
          - URL of GraphQL endpoint
          - Multiple files with type definitions (glob expression)
          - String in config file

        Try to use one of above options and run codegen again.
    Error: Failed to load schema
        at loadSchema (/workspace/node_modules/@graphql-codegen/cli/bin.
js:495:15)
        at processTicksAndRejections (node:internal/process/task_queues:
96:5)
        at async /workspace/node_modules/@graphql-codegen/cli/bin.js:907
:55
        at async Task.task (/workspace/node_modules/@graphql-codegen/cli
/bin.js:761:17)
    Error: Failed to load schema
        at loadSchema (/workspace/node_modules/@graphql-codegen/cli/bin.
js:495:15)
        at processTicksAndRejections (node:internal/process/task_queues:
96:5)
        at async /workspace/node_modules/@graphql-codegen/cli/bin.js:907
:55
        at async Task.task (/workspace/node_modules/@graphql-codegen/cli
/bin.js:761:17)


Something went wrong

Environment:

UPDATE: apparently this happens due to my containerized app. If I run the command in my local repo instead of inside my container it works just fine. Might need a workaround for this

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Lucasmiguelmaccommented, Feb 7, 2022

Yes, it seems to be a container-related thing. I’ll continue close the issue and try set up the networking. I might reopen it if the doubtious case that it is something else happens. Thank you very much

1reaction
ardatancommented, Feb 7, 2022

I’ll take a look at the reproduction but in the meanwhile could you make sure that URL is accessible with cURL inside the container?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js Error: connect ECONNREFUSED - Stack Overflow
ECONNREFUSED error means that connection could not be made with the target service (in your case localhost:8080 ). Check your service running on...
Read more >
Error: connect ECONNREFUSED 127.0.0.1:80 - Postman
It looks like you're sending a request to localhost:3000 , but your Proxy settings seem to be set to 127.0.0.1: 8080 Is your...
Read more >
Axios returns ECONNREFUSED 127.0.0.1:80 but port is set to ...
Axios sends an http request to the port specified in the url ... Error: connect ECONNREFUSED 127.0.0.1:80 at TCPConnectWrap.
Read more >
error: connect econnrefused 127.0.0.1:80 at tcpconnectwrap ...
Look for a line that says backend URL. Maybe no port is set there so it default to port 80 instead of the...
Read more >
How to Fix ECONNREFUSED – connection refused by server ...
If that's the cause of the Error: Connect econnrefused – connection refused by server error, simply disable the firewall and anti-virus software on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found