Describe the bug
When the connection string does not have a user specified, pgx will fail to connect due to
server error: FATAL: no PostgreSQL user name specified in startup packet (SQLSTATE 28000)
To Reproduce
Steps to reproduce the behavior:
package main
import (
"context"
"fmt"
"log"
"github.com/jackc/pgx/v5"
)
func main() {
connStr := "host=/var/run/postgresql/ port=5432 dbname=maas_test user="
conn, err := pgx.Connect(context.Background(), connStr)
if err != nil {
log.Fatal("Connection failed:", err)
}
defer conn.Close(context.Background())
}
Expected behavior
The same connection string work with many other drivers (python-asyncpg for example) and with psql itself
psql "host=/var/run/postgresql/ port=5432 dbname=maasdb user="
this is because they automatically pick the current user executing the application.
ubuntu@maas-noble:/tmp/test$ psql "host=/var/run/postgresql/ port=5432 dbname=maasdb user="
psql (16.11 (Ubuntu 16.11-0ubuntu0.24.04.1))
Type "help" for help.
maasdb=> \conninfo
You are connected to database "maasdb" as user "ubuntu" via socket in "/var/run/postgresql/" at port "5432".
Actual behavior
Crashes with
2026/01/30 22:20:56 Connection failed:failed to connect to `user= database=maas_test`: /var/run/postgresql/.s.PGSQL.5432 (/var/run/postgresql/): server error: FATAL: no PostgreSQL user name specified in startup packet (SQLSTATE 28000)
Version
- Go: go version go1.24.4 linux/amd64
- PostgreSQL: `$ PostgreSQL 16.11 (Ubuntu 16.11-0ubuntu0.24.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0, 64-bit
- pgx: v5.8.0
Describe the bug
When the connection string does not have a user specified, pgx will fail to connect due to
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The same connection string work with many other drivers (python-asyncpg for example) and with psql itself
this is because they automatically pick the current user executing the application.
Actual behavior
Crashes with
Version