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_nameError: 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 postgresFix:
# 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_passwordError: 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_passwordError: 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 poolingError: 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 socketError: 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.logQuick Diagnostic Table
| Error | Check | Fix |
|---|---|---|
| database does not exist | psql -l | createdb -O odoo dbname |
| connection refused | systemctl status postgresql | systemctl start postgresql |
| authentication failed | psql -U odoo -h localhost | Reset password or create user |
| too many connections | SELECT count(*) FROM pg_stat_activity | Increase max_connections |
| No such file or directory | ls /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.