Hi there,
I’m getting an ECONNREFUSED error when trying to hit one app, from another. I have a web
app and demo-services
app. The web is hitting the demo-services app. The demo-services fly.toml file looks like this:
app = "demo-services"
kill_signal = "SIGINT"
kill_timeout = 5
[processes]
worker = "yarn bull"
graphql = "bash -c 'yarn prisma migrate deploy && yarn start:graphql'"
webhook = "yarn start:webhook"
[deploy]
strategy = "rolling"
[env]
GRAPHQL_PORT = "8080"
WEBHOOK_PORT = "8000"
[experimental]
allowed_public_ports = []
auto_rollback = true
private_network = true
[[services]]
http_checks = []
internal_port = 8080
processes = ["graphql"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 50
soft_limit = 25
type = "connections"
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
[[services]]
http_checks = []
internal_port = 8000
processes = ["webhook"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 50
soft_limit = 25
type = "connections"
[[services.ports]]
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
You can see I have a couple different processes running, the one I’m trying to hit is graphql
, which is internal (not exposed to public internet).
The url I’m using is:
http://demo-services.internal:8080/graphql
They are both node apps, and the graphql service is listening using the following code:
httpServer.listen({ port: process.env.GRAPHQL_PORT, host: '::', ipv6Only: true })
The weirdest part is:
a.) It actually works sometimes, perhaps it’s something region related, or when my machine is in a new location for the first time?
b.) I can always successfully hit the URL from my machine if I’m connected to my orgs wireguard, so it doesn’t seem to be an issue there…
So this is the actual error I occasionally get:
2022-05-17T15:17:04.118 app[5c8eb155] ewr [info] FetchError: request to http://demo-services.internal:8080/graphql failed, reason: connect ECONNREFUSED fdaa:0:4934:a7b:2c01:da56:6713:2:8080
2022-05-17T15:17:04.118 app[5c8eb155] ewr [info] at ClientRequest. (/app/node_modules/node-fetch/lib/index.js:1491:11)
2022-05-17T15:17:04.118 app[5c8eb155] ewr [info] at ClientRequest.emit (node:events:527:28)
2022-05-17T15:17:04.118 app[5c8eb155] ewr [info] at Socket.socketErrorListener (node:_http_client:454:9)
2022-05-17T15:17:04.118 app[5c8eb155] ewr [info] at Socket.emit (node:events:527:28)
2022-05-17T15:17:04.118 app[5c8eb155] ewr [info] at emitErrorNT (node:internal/streams/destroy:164:8)
2022-05-17T15:17:04.118 app[5c8eb155] ewr [info] at emitErrorCloseNT (node:internal/streams/destroy:129:3)
2022-05-17T15:17:04.118 app[5c8eb155] ewr [info] at processTicksAndRejections (node:internal/process/task_queues:83:21) {
2022-05-17T15:17:04.118 app[5c8eb155] ewr [info] type: 'system',
2022-05-17T15:17:04.118 app[5c8eb155] ewr [info] errno: 'ECONNREFUSED',
2022-05-17T15:17:04.118 app[5c8eb155] ewr [info] code: 'ECONNREFUSED'
2022-05-17T15:17:04.118 app[5c8eb155] ewr [info] }
Any help would be greatly appreciated!
PS – I followed this thread: (Node) How do I connect to my API app from my WEB app in Fly?, but that didn’t seem to do the trick for me…