Published on

pg_dump fix: Parameter 'user' is missing in startup packet

Authors

When trying to take a backup of Postgres using pg-dump I came across this issue

pg_dump: error: connection to the server at "db.example.com" (1.1.1.1), port 5432 failed: ERROR:  Parameter 'user' is missing in startup packet.
pg_dump(64565,0x1024c4580) malloc: *** error for object 0x15b808c00: pointer being freed was not allocated
pg_dump(64565,0x1024c4580) malloc: *** set a breakpoint in malloc_error_break to debug
[1]    64565 abort      PGSSLMODE=require pg_dump --host  --port 5432 --user "db_username" "db_name"

I thought I was doing something wrong and spent a lot of time tinkering around the parameters and trying to figure out the issue (hello, ChatGPT 😅), I came across the potential solution

What's the issue?

So, my local machine was on Postgres 14 and the remote host that I was trying to backup was on Postgres 15.

You can run the following command to check it.

postgres --version

Potential Solution

  • Make sure that your version and the remote Postgres server are on the same version.
  • If not, update it locally to match the version that is running on the remote server.

In MacOS + Brew, you can update it easily with the following command:

postgres --version # postgres (PostgreSQL) 14 (Homebrew)

brew upgrade postgresql@15

postgres --version # postgres (PostgreSQL)  15.5 (Homebrew)

Happy fixing issues!