PostgreSQL error 08001 (Sqlclient Unable to Establish Sqlconnection) explained: what it means, why it happens, and how to fix it — with copy-paste code examples.
Verify host, port, database, and role in the connection string. If that does not apply, check pg_hba.conf and pg_ident.conf for the client's auth rule — the full checklist is below.
SQLSTATE: 08001
Official name: Sqlclient Unable to Establish Sqlconnection
Service: PostgreSQL
The SQL client could not establish a connection to the SQL server.
psql "postgresql://user:pass@host:5432/db?sslmode=require" -c 'SELECT 1;'
Connecting with psql isolates 08001 to network/auth vs your application code; a clear error pinpoints the cause.
Use the sslmode option in OPTIONS and verify the DB host resolves.
DATABASES = {'default': {
'OPTIONS': {'sslmode': 'require'}
}}
Use the direct connection URL (port 5432) with sslmode=require; whitelist your IP if restricted.
postgresql://postgres.[ref]:[pass]@db.[ref].supabase.co:5432/postgres?sslmode=require
Most often this happens when wrong host/port or firewall blocking the connection, or when authentication failure (wrong password, missing role, pg_hba.conf mismatch).
Verify host, port, database, and role in the connection string.
This page documents fixes for: django, supabase.
Recommendations are editorial — DB Error Reference takes no payment or affiliate fees for tool listings.
This page is based on the official PostgreSQL documentation linked below and adds practical troubleshooting guidance on top.