`PQsocket() can't get socket descriptor` multiple times with a brand new database

I have an app that was using Postgres 15. Today I decided to upgrade to 17 so I created a new pg app with fly pg create and it is now running the correct version

MACHINE ID      REGISTRY                        REPOSITORY              TAG     VERSION DIGEST                                                                   LABELS
7843d41ad32128  docker-hub-mirror.fly.io        flyio/postgres-flex     17.2    v0.0.66 sha256:f4301ae20d193ab3c3539eb9df9a8f8d3736dd331aeec1bfb2e34b539dc353c5  org.opencontainers.image.version=24.04fly.app_role=postgres_clusterfly.pg-manager=repmgrfly.pg-version=17.2fly.version=v0.0.66org.opencontainers.image.ref.name=ubuntu

I then imported the old database with fly pg import postgres://old -a new-db and everything worked as expected, except these errors that randomly pop up:

PG::ConnectionBad
PQsocket() can't get socket descriptor (PG::ConnectionBad)
PG::ConnectionBad
connection to server at "fdaa:0:6c8d:0:1::9", port 5432 failed: server closed the connection unexpectedly (PG::ConnectionBad)
	This probably means the server terminated abnormally
	before or while processing the request.
ActiveRecord::ConnectionNotEstablished
connection to server at "fdaa:0:6c8d:0:1::9", port 5432 failed: server closed the connection unexpectedly (ActiveRecord::ConnectionNotEstablished)
	This probably means the server terminated abnormally
	before or while processing the request.

These errors above are from the same error instance on Sentry.

I can’t for the life of me understand what’s going on. There is no pattern here, they randomly pop up and then go away after a refresh but Sentry is getting filled with these errors

The database URL is something like this: postgres://user:pass@app.flycast:5432/switchboard?sslmode=disable

the connection to server at "fdaa:0:6c8d:0:1::9" part of error smells like some sort of hiccup between the servers, on a network level maybe, I don’t know. I’m out of ideas here

edit: noticed that the errors timestamp match with this log from the postgres app:

2025-03-21T22:33:05Z proxy[7843d41ad32128] ams [error][PP02] could not proxy TCP data to/from instance: failed to copy (direction=client->server, op=shutdown_write, error=Transport endpoint is not connected (os error 107))
2025-03-21T22:33:05Z proxy[7843d41ad32128] ams [error][PP02] could not proxy TCP data to/from instance: failed to copy (direction=client->server, op=shutdown_write, error=Transport endpoint is not connected (os error 107))
2025-03-21T22:33:05Z proxy[7843d41ad32128] ams [error][PP02] could not proxy TCP data to/from instance: failed to copy (direction=client->server, op=shutdown_write, error=Transport endpoint is not connected (os error 107))
2025-03-21T22:33:05Z proxy[7843d41ad32128] ams [error][PP02] could not proxy TCP data to/from instance: failed to copy (direction=client->server, op=shutdown_write, error=Transport endpoint is not connected (os error 107))
2025-03-21T22:33:05Z proxy[7843d41ad32128] ams [error][PP02] could not proxy TCP data to/from instance: failed to copy (direction=client->server, op=shutdown_write, error=Transport endpoint is not connected (os error 107))

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