How to Configure Database Connection Parameters in Odoo 19
In any Odoo installation, the database connection is perhaps the most important configuration you will set. Get it right and Odoo talks to PostgreSQL reliably and securely; get it wrong and you face "connection refused", authentication failures, or "too many clients" errors. All of this is controlled by the odoo.conf file. This complete tutorial is a step by step beginner guide to configuring database connection parameters in Odoo 19, every key option explained, with copy-paste example configs for single-server, multi-database, and remote setups, plus how to test the connection and harden it for production.
What You'll Learn:
- Every core parameter: db_host, db_port, db_user, db_password, db_name
- Advanced options: dbfilter, db_maxconn, db_template
- Ready-to-use configs for single-server, multi-database, and remote setups
- How to create a dedicated PostgreSQL user and protect odoo.conf
- How to test connections and fix common errors
- Production best practices, including SSL
Core Database Connection Parameters
db_host, db_port, db_user, db_password, db_name
db_host tells Odoo where PostgreSQL runs (localhost, an IP, or a hostname). db_port is the port (default 5432). db_user is the connecting user, db_password its password, and db_name the database to connect to (set False to show the database selection screen).
| Parameter | Purpose | Example |
|---|---|---|
| db_host | Where PostgreSQL runs | localhost / 192.168.1.20 |
| db_port | PostgreSQL port | 5432 (default) |
| db_user | Database user | odoo |
| db_password | User password | T7#kL92!xQp@8 |
| db_name | Database to connect | False / production_db |
| dbfilter | Limit exposed databases (regex) | ^%d$ / ^mycompany.*$ |
| db_maxconn | Max concurrent connections | 64 (default) |
| db_template | Template for new databases | template0 |
Create a Dedicated PostgreSQL User
Use a dedicated odoo user rather than the PostgreSQL superuser for increased security and easier management of user rights. Then protect odoo.conf with restricted file permissions so the password is not world-readable.
# Create a dedicated Odoo PostgreSQL user
sudo -u postgres createuser -s odoo
sudo -u postgres psql
ALTER USER odoo WITH PASSWORD 'admin';
# Protect the configuration file
chmod 640 /etc/odoo.conf
chown odoo:odoo /etc/odoo.conf
dbfilter, db_maxconn, db_template
dbfilter restricts which databases are available (e.g. ^%d$ for domain-based filtering). db_maxconn caps connections (default 64; plan as workers x connections-per-worker). db_template sets the template for new databases, use template0 for a clean setup or template1 to include existing objects.
Example Configurations
Pick the example closest to your deployment and adapt the values.
# Single-server production
[options]
db_host = localhost
db_port = 5432
db_user = odoo
db_password = StrongPassword123
db_name = production_db
db_maxconn = 64
# Multi-database (domain-based)
[options]
db_host = localhost
db_port = 5432
db_user = odoo
db_password = StrongPassword123
db_name = False
dbfilter = ^%d$
db_maxconn = 128
# Remote PostgreSQL server
[options]
db_host = 10.0.0.15
db_port = 5432
db_user = odoo
db_password = StrongPassword123
db_name = False
Restart and Test the Connection
After editing odoo.conf, restart the service, follow the logs, and verify connectivity directly with psql before assuming the app config is the problem.
# Restart Odoo and watch logs
sudo systemctl restart odoo
sudo journalctl -u odoo -f
# Test local / remote PostgreSQL connection
psql -h localhost -U odoo -d postgres
psql -h 10.0.0.15 -U odoo -d postgres
# Find the active PostgreSQL port
sudo ss -plunt | grep postgres
Common Connection Errors
| Error | Cause | Solution |
|---|---|---|
| password authentication failed | Wrong credentials or pg_hba.conf | Verify password, username, and config |
| database does not exist | Wrong database name | Check with: psql -U postgres -l |
| too many clients already | Connection limits exceeded | Adjust db_maxconn or max_connections |
| timeout expired | Network or firewall issues | Verify connectivity and firewall rules |
Connection Refused?
A "connection refused" error usually means PostgreSQL isn't running, a firewall is blocking port 5432, or PostgreSQL isn't listening on the right IPs. Check listen_addresses = '*' in postgresql.conf.
Best Practices
Secure the Connection
Use a dedicated user, restrict odoo.conf permissions, and add SSL for production since the connection is unencrypted by default, via an SSL-enabled PostgreSQL, private networking, or a VPN.
Isolate and Monitor
Use dbfilter for database isolation, avoid single-server setups for production where possible, and monitor connections with: SELECT * FROM pg_stat_activity;
Key Insight:
The database connection is the foundation of every Odoo deployment. Set the core parameters carefully, size db_maxconn to your worker count, isolate databases with dbfilter, and never ship to production without a dedicated user, locked-down odoo.conf, and an encrypted connection.
Frequently Asked Questions
Where do I set database connection parameters in Odoo 19?
In the odoo.conf file under the [options] section. It controls how Odoo 19 connects to PostgreSQL via db_host, db_port, db_user, db_password, and db_name.
What is the default Odoo database port?
PostgreSQL's default port is 5432, set with db_port = 5432. You can use a custom port like 5433. Check the active port with: sudo ss -plunt | grep postgres.
What does db_maxconn do in Odoo?
It caps concurrent database connections (default 64). Plan it as worker count times connections per worker, for example 4 workers x 16 = 64 total.
What is dbfilter used for?
dbfilter limits which databases Odoo exposes using regex. For example dbfilter = ^%d$ filters databases by the domain name used to access Odoo, useful for multi-database hosting.
Is the Odoo database connection encrypted by default?
No. It is unencrypted by default. For production, secure it with an SSL-enabled PostgreSQL server, private cloud networking, and/or internal VPNs.
Need Help with Your Odoo Deployment?
Our Odoo experts can configure secure, high-performance database connections, set up multi-database hosting, and harden your odoo.conf for production. Get hands-on help with your Odoo 19 infrastructure.
About the author
Odoo Practice Lead, Braincuber Technologies
Leads the Odoo practice at Braincuber. Has delivered Odoo ERP implementations, NetSuite/Tally migrations, and Shopify–Odoo integrations for US mid-market and D2C brands. Owns scoping, data migration, and go-live for every Odoo engagement.
