Skip to content

Odoo 'FATAL: database does not exist' & PostgreSQL Connection Errors — Fixes

DeployMonkey Team · March 22, 2026 9 min read

PostgreSQL Connection Errors in Odoo

Odoo relies entirely on PostgreSQL for data storage. When the database connection fails, nothing works. Here are the most common PostgreSQL errors and their fixes.

Error: FATAL: database "dbname" does not exist

Cause: Odoo is configured to connect to a database that has not been created.

Fix:

# Create the database
sudo -u postgres createdb -O odoo your_database_name

# Or in odoo.conf, match the database name:
db_name = your_database_name

Error: Connection refused

Cause: PostgreSQL is not running, or Odoo is connecting to the wrong host/port.

Diagnosis:

# Check if PostgreSQL is running
systemctl status postgresql

# Check which port PostgreSQL listens on
grep port /etc/postgresql/16/main/postgresql.conf

# Test connection
psql -U odoo -h localhost -p 5432 -d postgres

Fix:

# Start PostgreSQL
systemctl start postgresql

# Verify odoo.conf matches PostgreSQL settings:
db_host = localhost  # or False for local socket
db_port = 5432
db_user = odoo
db_password = your_password

Error: password authentication failed for user "odoo"

Cause: Wrong password in odoo.conf or user does not exist in PostgreSQL.

Fix:

# Check if user exists
sudo -u postgres psql -c "\du" | grep odoo

# Create user if missing
sudo -u postgres createuser -s odoo

# Reset password
sudo -u postgres psql -c "ALTER USER odoo WITH PASSWORD 'new_password';"

# Update odoo.conf
db_password = new_password

Error: FATAL: too many connections for role "odoo"

Cause: More Odoo workers + crons than PostgreSQL allows.

Fix:

# Check current connections
sudo -u postgres psql -c "SELECT count(*) FROM pg_stat_activity;"

# Increase max_connections in postgresql.conf
max_connections = 200  # Default is 100

# Restart PostgreSQL
systemctl restart postgresql

# Better: add PgBouncer for connection pooling

Error: could not connect to server: No such file or directory

Cause: Odoo is trying to connect via Unix socket but the socket file is missing.

Fix:

# Check socket location
ls /var/run/postgresql/.s.PGSQL.5432

# If missing, PostgreSQL is not running or using a different socket dir
# In odoo.conf, use TCP instead:
db_host = localhost  # Forces TCP connection instead of socket

Error: SSL connection has been closed unexpectedly

Cause: PostgreSQL crashed or was restarted while Odoo was connected.

Fix:

# Restart Odoo to re-establish connections
systemctl restart odoo

# Check PostgreSQL logs for crash reason
tail -100 /var/log/postgresql/postgresql-16-main.log

Quick Diagnostic Table

ErrorCheckFix
database does not existpsql -lcreatedb -O odoo dbname
connection refusedsystemctl status postgresqlsystemctl start postgresql
authentication failedpsql -U odoo -h localhostReset password or create user
too many connectionsSELECT count(*) FROM pg_stat_activityIncrease max_connections
No such file or directoryls /var/run/postgresql/Set db_host = localhost

Prevention

DeployMonkey manages PostgreSQL configuration automatically. The AI agent monitors database connections, detects failures, and alerts before they impact users. No PostgreSQL administration needed.