Unable to connect to Postgres DB server via external

I created a Postgres instance in Fly.io and wanted to connect the database via Pgadmin but receiving error “Unable to connect to server: connection failed: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request”.

I’m deploying with image flyio/postgres-flex:15.3 and have followed this tutorial Fly.io - Postgres - Connecting external to configure public IP for my instance but it’s still not working.

Monitoring also shows the instance is healthy and running.

What am I missing?

Hi,

Not sure if you have since got this working however you may be able to proxy to it using a local port.

Make sure you have the latest Fly CLI (often fixes many problems) then try:

fly proxy 15432:5432 --app your-db-app

You should then be able to connect to the database using the hostname localhost and the port 15432 (as that is the local port) which proxies to the remote 5432.

For more:

Any luck with that approach?

Another option is to install Wireguard and create a tunnel.

The tunnel config can be generated with fly wireguard create.

1 Like

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