Skip to main content

Troubleshooting "pg_restore: error: unsupported version (1.15) in file header"

When attempting to restore a PostgreSQL database using pg_restore, you might encounter the error: "pg_restore: error: unsupported version (1.15) in file header". This typically indicates a version mismatch between the pg_dump used to create the backup and the pg_restore or PostgreSQL server version for the restore. Below are the steps to troubleshoot this issue:

Step 1: Verify pg_dump and PostgreSQL Versions

  • Check the version of pg_dump and PostgreSQL on both the source and destination servers.
    • Use pg_dump --version and psql --version.
    • Ensure that the pg_dump version matches or is compatible with the PostgreSQL server version where the backup was created.

Step 2: Resolve Version Mismatch

  • Upgrade the Receiving Server (if possible):

    • If the backup was created on a newer version (e.g., PostgreSQL 16), and you're restoring to an older version (e.g., PostgreSQL 15), consider upgrading the receiving server's PostgreSQL version.
  • Downgrade the Dump (if necessary):

    • If upgrading isn't possible, create a new dump using a pg_dump version that matches the destination server's version.
    • Consider using an intermediate server with the matching PostgreSQL version to create a compatible dump.

Step 3: Use Plain SQL Format for Cross-Version Compatibility

  • Create a Plain SQL Dump:
    • Use the --format=plain option in pg_dump for better compatibility across different PostgreSQL versions.
    • Example: pg_dump -Fp -h [host] -U [username] [dbname] > dumpfile.sql

Step 4: Importing the Dump into PostgreSQL 15

  • Prepare the Database:

    • Ensure the target database exists on the PostgreSQL 15 server.
  • Import Using psql:

    • Use the psql command to import the plain SQL dump.
    • Example: psql -U [username] -d [dbname] -f [dumpfile.sql]

Step 5: Troubleshoot Connection Issues

 
  • Addressing “Peer Authentication Failed” Error:
    • If you encounter an error like psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "user_054a46eda005", try the following:
      • Include -h localhost in the psql command.