Unable to connect to postgres via fly postgres connect, or proxy.

My app seems to be able to connect for the most part, but I’ve been unable to get manually connected to my postgres instance lately, and am stumped.

Here’s a few things I’ve tried:

  • fly postgres connect
Connecting to [ipaddress removed]... complete
psql: error: connection to server at "[dbapp removed].internal" ([ipaddress removed]), port 5432 failed: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
  • Running fly ssh console, and then psql, gives the error
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?
  • proxying the port and connecting using intellij ultimate (I’ve done this in the past and just used the saved configuration)

  • When running fly postgres config view, I get Error 500: context deadline exceeded.

The fly status for the app also shows the app as readonly which is curious.

Instances
ID              PROCESS VERSION REGION  DESIRED STATUS                  HEALTH CHECKS                   RESTARTS        CREATED
7e31e93a        app     18      dfw     run     running (readonly)      3 total, 1 passing, 2 critical  0               1m27s ago

Any ideas?

edit: Restarting I see this in the console

 2022-12-08T22:10:06.873 app[19b4912f] dfw [info] exporter | ERRO[0013] Error opening connection to database (postgresql://flypgadmin:PASSWORD_REMOVED@[ip removed]:5433/postgres?sslmode=disable): dial tcp [ip removed]:5433: connect: connection refused source="postgres_exporter.go:1658" 

Hi @chew, without analysing everything you’ve got there, one thing that sticks out for me is that a Fly Postgres app will go read-only if its disk is nearly full (because it gets more complicated to recover if it gets completely full).

You can check this by fly ssh console-ing in and running df.

If you need more space for your database, you can extend the volume on each instance.

1 Like

Yep that was it. Extended the volume and I’m able to connect again. Thanks for your help

1 Like