[PP02] could not proxy TCP data to/from instance: failed to copy client → server

I have a backend server running a Python app listening on websocket and api, on ports 9000 and 8080. Working fine, however recently I have seen some issues without any change on code which are fixed just by restarting server:

[PP02] could not proxy TCP data to/from instance: failed to copy (direction=client->server, op=read, error=Connection reset by peer (os error 104))

[PC05] timed out while connecting to your instance. this indicates a problem with your app (hint: look at your logs and metrics)

My fly toml shows as:

[[services]]
internal_port = 8088
force_https = true
auto_stop_machines = ‘off’
auto_start_machines = true
min_machines_running = 0
processes = [‘app’]

[[services.ports]]
handlers = [“tls”, “http”]
port = 8088

[[services]]
internal_port = 9000
force_https = true
auto_stop_machines = ‘off’
auto_start_machines = true
min_machines_running = 0
processes = [ “app” ]
protocol = “tcp”

[[services.ports]]
handlers = [“tls”]
port = 9000

[[services.consoles]]
internal_port = 22

[proxy]

#Bind address for the proxy to listen on.
addr = “9000”

#Hostport of your application.
target = “0.0.0.0:9000”

Any ideas what could be happening?

Thanks!!

Tip: in this forum software, config files, error logs, code etc can be formatted using a Markdown code block.

Hey @josalvmo

Since this happened while reading (op=read) from a client connection (client→server) this likely means a client simply dropped a connection without properly closing it. So not really a problem with the app.

This looks like your app stopped accepting new connections. There is still a listening socket (otherwise it would’ve been “connection refused”), but the app is not calling accept on the new connections, so TCP handshake doesn’t happen. Looking at the metrics for that time period it looks like the app simply stopped doing anything (no I/O, CPU usage dropped).

Is it an async Python app? Is it possible you have a heavy blocking task there that prevents event loop from progressing?