need data recovery from crashed PostgreSQL volume
ricardobsjunior
HOBBYOP

a month ago

Hi Railway team,

I have a PostgreSQL service that is crash-looping due to a version mismatch (data directory initialized with PG18, service running PG16). The service shows as "Online" in the dashboard but refuses all connections with "server closed the connection unexpectedly".

I need to recover the data from the volume postgres-volume-gtrh attached to the service Postgres in project anotou-app, environment production.

Could you please either:

Restore the service to a working state so I can dump the data, or

Provide a data dump directly from the volume

This is a production database with real customer data. Any help is greatly appreciated.

Thank you.

$10 Bounty

4 Replies

Status changed to Open Railway about 1 month ago


Go to your service and change the image tag to use version 16 instead of 18.


ricardobsjunior
HOBBYOP

a month ago

Hi,

I've been dealing with a crash loop on my PostgreSQL service. The error in the logs is:

FATAL: database files are incompatible with server

DETAIL: The data directory was initialized by PostgreSQL version 18, but the server was started by version 16.

I followed the suggestion to switch the image from postgres:18 to postgres:16 and also tried postgres:16-alpine, but the service still fails with the same connection error:

connection to server failed: server closed the connection unexpectedly

The data directory was initialized with PG18, so downgrading to PG16 will never work — the data format is not backwards compatible. The only images that can read this data directory are PG18 or higher.

What I've already tried:

postgres:16 — same error

postgres:16-alpine — same error

Connecting via pgAdmin — fails with "server closed the connection unexpectedly"

Railway CLI railway connect — fails, looking for DATABASE_PUBLIC_URL

What I need:

The data directory on volume postgres-volume-gtrh was written by PG18. I need either:

The image forced back to postgres:18 so the service can start and I can dump the data, or

A direct dump of the volume contents by the Railway team

Is there a way to pin the image to exactly postgres:18 and prevent auto-updates from changing it again? That appears to be what caused this in the first place — the image was auto-updated to a lower version.

Thank you.


If postgres data on the volume was initialized by version 18, your postgres version running on the service must be 18 as well. You can change the version in settings > source.

image.png

Attachments


You can disable automatic upgrades from here:

47233.png

Attachments


Welcome!

Sign in to your Railway account to join the conversation.

Loading...