Could not find a good candidate within 1 attempts at load balancing. [PC01] instance refused connection

I’m getting these errors in production:

proxy[d8d9790b279548] den [error] [PR03] could not find a good candidate within 1 attempts at load balancing. last error: [PC01] instance refused connection. is your app listening on 0.0.0.0:8081? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)

I haven’t changed anything in the toml file or similar, any insights about the cause?

Hi… Typically you would SSH in at this point and then try to connect to localhost:8081 via curl and/or use ss -tpnl to see all listening processes.

(This assumes an HTTP service, of course.)

On Debian, ss is in the iproute2 package.

Done, I checked that it’s running in 8080:
Screenshot 2025-08-05 at 8.53.30 PM

For some reason, deployment logs still says:

2025-08-06T00:49:10.455 proxy[2866994fe413e8] den [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)


Hm… The other Machine was saying port 8081. What does your fly.toml look like?


Also, it probably help to post the outputs of fly m list and fly services list, so we in the forum have a better idea of what regions you’re in, and the like…

yeah I changed all the config to 8080

[env]
PORT = ‘8080’

[http_service]
internal_port = 8080

[[services]]
internal_port = 8080
protocol = “tcp”

Here are my services list:

Services
PROTOCOL        PORTS           HANDLERS        FORCE HTTPS     PROCESS GROUP   REGIONS                 MACHINES 
TCP             80 => 8080      [HTTP]          True            app             scl,den,cdg,otp,bom     7       
TCP             443 => 8080     [HTTP,TLS]      False           app             scl,den,cdg,otp,bom     7       
TCP             80 => 8080      [HTTP]          False           app             scl,den,cdg,otp,bom     7       
TCP             443 => 8080     [TLS,HTTP]      False           app             scl,den,cdg,otp,bom     7       

Having both [http_service] and [[services]] define the same port often (randomly) confuses the Fly.io infrastructure.

Try removing [[services]] entirely…

(And merge any config knobs into the surviving stanza, of course, :sweat_smile:.)

1 Like

Yeah in my desperation I tried adding the [[services]] config, now I tried without it again and I still get the error log in the machines when deploying:

2025-08-06T01:42:41.017 proxy[d8d9790b279548] scl [error] [PR03] could not find a good candidate within 1 attempts at load balancing. last error: [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)


Are you able to get any requests through at all, or is it always these errors?

That’s the weird part, the requests and app work regardless, but I’ve been having 504 errors from the API and I’m suspecting it could be because of this.

There have been false positives with similar messages reported in the forum in the past:

https://community.fly.io/t/litefs-warning-the-app-is-not-listening-on-the-expected-address-and-will-not-be-reachable/21311

The API anomalies might not be related (although possibly I’m misunderstanding what you’re referring to there).

If the app that you’re getting these errors in doesn’t use volumes, then I would try destroying the two Machines that have been mentioned in the logs so far (d8d9790b279548 and 2866994fe413e8)—and then recreating them.

More broadly, see if there’s some correlation with Machines, regions, and the like…

You can use the client-side Fly-Prefer-Region and Fly-Force-Instance-Id headers to steer requests to particular locales.

$ curl -i -H 'Fly-Prefer-Region: otp' -H 'flyio-debug: doit' 'https://debug.fly.dev/'
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.