You start your Odoo server, and instead of the login page you see the connection refused message. It is one of the most common problems after an installation, a server migration, a system update, or a network configuration change. The good news is that the cause almost always lies in one of a few places: the PostgreSQL database, the configuration file, the network firewall, the proxy server, or the container setup. In this article, we show how to systematically find and fix the problem in current Odoo versions.
If you want to see how a stable, ready-to-use Odoo environment works, start with a trial version.
What does the connection refused error mean in Odoo?
The connection refused message means that the target system actively rejected the connection attempt. Nothing is listening at the given address and port, or a firewall is rejecting the traffic. This is different from a timeout, where no response arrives at all.
In Odoo, the error can appear in two places:
- During server startup – Odoo cannot connect to PostgreSQL (usually port 5432). The logs will then show an entry similar to:
psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused. - In the browser – the web server (Odoo on port 8069 or a reverse proxy on 80/443) is not accepting connections, so the page does not open.
Before you change anything, determine which of these scenarios applies to you. Further diagnostics depend on it. Keep in mind that the steps below apply to installations on your own infrastructure (on-premise, VPS, Docker). With Odoo Online and Odoo.sh, the infrastructure is managed by the provider, and issues should be reported to support.
The most common causes of the error at startup
1. The PostgreSQL service is not running
The simplest cause is a stopped database. After a server restart, the service may not have started automatically or may have ended with an error (e.g., due to a lack of disk space). Check the status with this command:
sudo systemctl status postgresqlIf the service is not running, start it and enable autostart:
sudo systemctl start postgresql
sudo systemctl enable postgresqlIf the service still does not start, you will find the reason in the PostgreSQL logs (usually in the /var/log/postgresql/ directory).
2. Incorrect parameters in the odoo.conf file
Odoo connects to the database based on the parameters in the configuration file, usually /etc/odoo/odoo.conf. Check the following in particular:
db_host– the database server address (e.g.,localhost,127.0.0.1, or the container name),db_port– 5432 by default,db_useranddb_password– the PostgreSQL user credentials.
A db_host = False value means the connection is made through a local Unix socket rather than over the network. If the database runs on another server or in a container, you must provide its address or hostname. Another common mistake is a typo in the port after moving the installation to a new machine, as well as an outdated database user password.
3. PostgreSQL is not listening on the correct address
When the database runs on a separate server, check the listen_addresses parameter in postgresql.conf. The default value localhost prevents external connections. In addition, the pg_hba.conf file must contain a rule allowing the Odoo user to connect from the application server's address. Restart PostgreSQL after making changes. Note that a missing rule in pg_hba.conf usually results in a different message (authentication failure), not connection refused. The latter points rather to a lack of listening or a firewall block.
4. The port is in use or blocked by a firewall
If another process has taken port 8069, Odoo will not start correctly (the logs will show an address-in-use message). Check what is listening on the ports:
sudo ss -tlnp | grep -E '8069|8072|5432'If you are connecting from outside, make sure the firewall (e.g., UFW, firewalld, or rules in the cloud panel) allows the necessary traffic. In production, usually only ports 80 and 443 are exposed publicly, while Odoo stays behind a reverse proxy. The PostgreSQL port should not be accessible from the internet.
5. Problems in a Docker environment
In containers, localhost refers to the Odoo container itself, not the database container. Set db_host (or the HOST environment variable in the official Odoo image) to the service name from the docker-compose file (e.g., db), along with the correct USER and PASSWORD. Also pay attention to the startup order: PostgreSQL needs a moment to initialize, so Odoo may try to connect too early. A healthcheck with the pg_isready command and depends_on with the condition: service_healthy setting help here.
Step-by-step diagnostics
Instead of guessing, go through a simple checklist:
- Check whether PostgreSQL is running (
systemctl status postgresql). - Test the connection manually:
psql -h localhost -p 5432 -U odoo -d postgres. If you also get a refusal manually, the problem lies with the database or the network, not Odoo. - Verify the parameters in
odoo.conf. - Check whether Odoo is listening on port 8069 (
ss -tlnp). - Review the service logs:
sudo journalctl -u odoo -n 100 --no-pager. The service name depends on the installation (e.g.,odooorodoo-server). - Check the firewall and the reverse proxy configuration.
Logs are the most important source of information. If you are not yet saving them to a file, use our guide: How to Configure File Logging in Odoo: Step-by-Step Guide. With persistent logs, it is easier to reconstruct what happened when the error occurred.
Once you have fixed your environment, see how smoothly Odoo runs without infrastructure problems.
Reverse proxy and browser errors
If Odoo is running but the browser shows connection refused or a 502 error, check your Nginx or Apache configuration. The proxy_pass directive should point to the correct address, e.g., http://127.0.0.1:8069. When running behind a proxy, also set proxy_mode = True in odoo.conf and make sure the proxy passes the X-Forwarded-For, X-Forwarded-Proto, and Host headers.
Also remember the separate port for real-time connections (gevent, the gevent_port parameter, 8072 by default; longpolling_port in older versions). It is used when Odoo runs with multiple workers (workers greater than 0). The /websocket path must be routed through the proxy to this port. If it points to an inactive port, some features, such as chat or notifications, will stop working. You can find configuration details in the article How to Configure Odoo with Multiple Workers?.
Redis and other external services
A standard Odoo installation does not require Redis. However, if it has been added to your environment (e.g., to store sessions or cache using additional modules, such as OCA community solutions), the connection refused error may come from there. Check that the service is running, that it is listening on the correct port (6379 by default), and that the configuration details match. This guide will help: How to Configure Redis for Odoo: Step-by-Step Guide.
A complex infrastructure with containers, a proxy, and a separate database server can be difficult to sort out on your own, so it is worth getting support from specialists.
How to prevent the error in the future?
- Enable autostart for PostgreSQL and Odoo, and make sure Odoo starts after the database.
- Monitor services and disk space. A full disk can stop PostgreSQL.
- Document your configuration and keep the
odoo.conffile under version control (without passwords). - Test changes in a test environment before deploying to production, and keep a backup copy of the configuration ready.
- Take care of performance – an overloaded server more often ends in timeouts, 502/504 errors, or exhausting the database connection limit (
max_connections), which is easy to mistake for a connection refusal. See: How to Optimize Odoo Performance? Proven Methods.
FAQ – frequently asked questions
Why does Odoo report connection refused only after a server restart?
Most often, PostgreSQL has not started yet or does not have autostart enabled. Odoo tries to connect to a database that is not accepting connections at that moment. Enable autostart for the database service and make sure Odoo starts after it.
Can I check the database connection without starting Odoo?
Yes. Use the psql client with the same parameters you have in odoo.conf (host, port, user). If the connection fails, the cause lies in PostgreSQL, the network, or the firewall, not in Odoo itself.
What should I do when Odoo cannot see the database in Docker?
Set the database address to the service name from the docker-compose file instead of localhost, check the login credentials, and add a healthcheck for PostgreSQL (pg_isready) so that Odoo starts only after it is fully up.
Summary
The connection refused error when starting Odoo is usually a configuration issue rather than a failure of the system itself. Check in order: PostgreSQL operation, parameters in odoo.conf, port listening, the firewall, the proxy, and container settings. With logs and simple connection tests, you will quickly narrow down the cause and restore the system.
Don't have time for your own diagnostics, or want to be sure your Odoo environment is configured correctly? The KK Innovations team will help you fix the error, implement, and optimize your system.