request to url failed, reason: connect ECONNR EFUSED 127.0.0.1:8001
See original GitHub issueDescribe the bug
To Reproduce Steps to reproduce the behavior:
- Start a blank Svelte project
- 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
- 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"
- Create a script in
package.json
for codegen:
{
...
"scripts": {
...
"generate": "graphql-codegen --config codegen.yml"
...
}
...
}
-
Have a backend API running on localhost:8001
-
Run
npm run generate
-
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:
- OS: Containerized debian installed in Artix Linux.
- Codegen versions β@graphql-codegen/cliβ: β^1.9.0β, β@graphql-codegen/typescriptβ: β^2.4.3β, β@graphql-codegen/typescript-operationsβ: β^2.2.4β, β@graphql-codegen/typescript-urqlβ: β^3.5.1β, β@graphql-codegen/urql-introspectionβ: β^2.1.1β, β@graphql-codegen/urql-svelte-operations-storeβ: β^1.1.10β,
- Node version: v16.13.2
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:
- Created 2 years ago
- Comments:8
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
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?