pg_dump refuses to run: server version is newer than pg_dump
pg_dump: error: aborting because of server version mismatchShort answer
pg_dump will not dump a server whose major version is newer than its own. Your PATH finds an older pg_dump than the server. Install the client package for the server's major version, call that binary by full path, or run pg_dump on the server host.
Fix it fast
1Find out which cause you have
Compare the server's version with the pg_dump that your shell actually runs.
psql -h dbhost -U appuser -d appdb -Atc "SHOW server_version" which -a pg_dump; pg_dump --version2Match what you see, then jump to its fix
- 1
The detail line shows a server version with a higher major number than pg_dumpThe client tools are an older major version than the serverFix - 2
which -a shows more than one pg_dumpSeveral PostgreSQL versions are installed and PATH picks the old oneFix - 3
You cannot or do not want to install new client tools on this machineDump on the server host insteadFix
- 1
What does the error look like?
pg_dump: error: aborting because of server version mismatchpg_dump: detail: server version: 17.2; pg_dump version: 14.13
Cause 1 of 3
The client tools are an older major version than the server
1Check
pg_dump refuses servers newer than itself instead of risking an invalid dump. Its output can load into newer servers, but it cannot read from them.
pg_dump --version2Fix
Install the client package of the server's major version from the PostgreSQL apt repository, then run that version's binary.
sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
sudo apt install -y postgresql-client-17
/usr/lib/postgresql/17/bin/pg_dump -h dbhost -U appuser -Fc -f appdb.dump appdb3Verify
The dump file is created and pg_restore can list it.
pg_restore --list appdb.dump | headConfirmed by postgresql.org
Cause 2 of 3
Several PostgreSQL versions are installed and PATH picks the old one
1Check
The first pg_dump on PATH runs, regardless of the server you are dumping.
which -a pg_dump2Fix
Call the right binary by its full path, or put that directory first on PATH for the session.
# Debian/Ubuntu package layout
/usr/lib/postgresql/17/bin/pg_dump --version
export PATH=/usr/lib/postgresql/17/bin:$PATH3Verify
pg_dump --version reports the server's major version.
pg_dump --versionConfirmed by postgresql.org
Cause 3 of 3
Dump on the server host instead
1Check
pg_dump that ships with the server is always the same major version as the server.
ssh dbhost 'pg_dump --version'2Fix
Run pg_dump on the server host and copy the file, which the custom format keeps compressed and restorable with pg_restore.
ssh dbhost 'pg_dump -U appuser -Fc appdb' > appdb.dump3Verify
The file is not empty and lists its contents.
pg_restore --list appdb.dump | headConfirmed by postgresql.org
How do I stop it coming back?
- Upgrade the client tools together with the server (same major version, or newer).
- In backup scripts, call pg_dump by full path instead of relying on PATH.
- Restore a test dump after each major upgrade.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Databases
DBeaver cannot run pg_restore: the utility is not found in the client home
Utility 'pg_restore' not found in client home '/usr/lib' (/usr/lib)
DBeaver runs pg_restore from a local PostgreSQL client folder; it does not bundle one.
3 causes, each with a fixDatabases
Django cannot connect to PostgreSQL: connection refused on port 5432, locally or in Docker
Is the server running on that host and accepting TCP/IP connections?
Connection refused means nothing accepted the connection at the host and port Django used.
4 causes, each with a fixDatabases
manage.py test stops with 'permission denied to create database' on PostgreSQL
django.db.utils.ProgrammingError: permission denied to create database
Django creates a separate database called test_ plus your database name, using the DATABASES USER.
2 causes, each with a fixDatabases
An EC2 instance cannot reach its RDS database
Could not open connection to the host, on port <port>: Connect failed
RDS denies all access until a security group allows it.
3 causes, each with a fixDatabases
IntelliJ IDEA Test Connection fails for a PostgreSQL data source
Connection to localhost:5432 refused.
When Test Connection fails, work from the bottom up.
4 causes, each with a fixDatabases
Postgres cannot find the vector type for pgvector
ERROR: type "vector" does not exist
Installing pgvector on the server is not enough.
3 causes, each with a fix