How I can change the Postgress to 16?
kriss145
PROOP

10 months ago

Hello! I would to use the 16 version od Postgress but now I don't know how I can change it. I changed the version to 16 but is crashed.

2025-12-15 14:54:39.838 UTC [6] FATAL: database files are incompatible with server

2025-12-15 14:54:39.838 UTC [6] DETAIL: The data directory was initialized by PostgreSQL version 17, which is not compatible with this version 16.11 (Debian 16.11-1.pgdg13+1).

$10 Bounty

2 Replies

10 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open ray-chen • 10 months ago


10 months ago

Hey, I would personally just wipe the volume of your Postgres database, if it is empty and has already been initialized with a different version, this way, it will reinitialize itself with Postgres 16.


mujirin
PRO

10 months ago

Hi, my story might help you. I have similar problem in my Django app with Postgres database, I have solved the problem, here the summary:

The error:

App do not respond

502 Bad Gateway

The log:

DETAIL: The database was created using collation version 2.36, but the operating system provides version 2.41.

HINT: Rebuild all objects in this database that use the default collation and run ALTER DATABASE railway REFRESH COLLATION VERSION, or build PostgreSQL with the right library version.

Operations to perform:

Apply all migrations:

What I am done to fix:

1. Backup in the local

BACKUP

436 export PGHOST="pghost"

437 export PGPORT="pgport"

438 export PGUSER="pguser"

439 export PGPASSWORD="pgpassword"

440 export PGDATABASE="pgdatabase"

441 export PGSSLMODE="require"

442 pg_dump --no-owner --no-privileges --format=plain > backup.sql

after finish

443 ls

you will get

backup.sql

  1. TEST

444 createdb test_restore\npsql test_restore < backup.sql\npsql test_restore -c "\dt"\n

you will get error here

  1. ALTER and REINDEX

445 psql -d postgres -c "ALTER DATABASE template1 REFRESH COLLATION VERSION;"\n

446 psql -d postgres -c "ALTER DATABASE postgres REFRESH COLLATION VERSION;"\n

447 psql -d postgres -c "ALTER DATABASE railway REFRESH COLLATION VERSION;"\n

448 psql -d postgres -c "REINDEX DATABASE railway;"\n

449 psql -d railway -c "REINDEX DATABASE railway;"\n

450 psql -d postgres -c "ALTER DATABASE postgres REFRESH COLLATION VERSION;"\n

451 psql -d postgres -c "ALTER DATABASE railway REFRESH COLLATION VERSION;"\n

452 psql -d railway -c "REINDEX DATABASE railway;"\n

453 psql -d railway -c "SELECT current_database();"\n

454 psql -d railway -c "VACUUM (ANALYZE);"\n

455 psql -d railway -c "SELECT pg_database_size(current_database());"\n

Hope this help you.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...