Running Odoo with PostgreSQL on a separate server

Moving PostgreSQL off the Odoo application host is a network, authentication and permissions change that needs planning. This page covers the options, setup sequence and limits to confirm.

On this page

When running Odoo with PostgreSQL on a separate server makes sense

Splitting the database tier moves PostgreSQL off the machine that runs the Odoo server, so the two compete for CPU, memory and disk less and can be secured, patched and backed up as separate systems. Your self-hosted install probably began on one machine, which is common for a first deployment. The trigger to split is usually one of three things: the database needs isolation from the application network, a backup or disaster recovery policy requires the database on its own host, or the shared machine no longer has the capacity for both workloads. Name the trigger in writing before you change anything, because it determines whether a second server alone solves the problem or whether you also need storage, replication or pooling work.

Odoo's on-premise documentation covers installation and configuration in general terms, and the connection between the application and the database is set through Odoo's configuration file rather than through code changes. Both the Community and Enterprise editions run on Python and PostgreSQL, so the database tier decision is the same for either edition, although the Enterprise subscription activation and upgrade service are separate concerns. Confirm the PostgreSQL version your target Odoo release supports in the release documentation for that version, not in older guides or forum posts, and confirm it again before the build starts. The Odoo on-premise documentation is the natural starting point for checking what the application expects from its environment.

Before you commit to the split, decide who will operate each tier. Someone must own PostgreSQL access rules, backups, restores and major version planning, and that person may not be the one who maintains the Odoo application. Ask whether your team can test restores from the database host, whether the network between the two hosts will stay private, and how many worker processes the application server will open to the database at peak. Those answers decide the scope of the work: a planned split with tested restores is a different project from a quick move that leaves the old backup routine in place. If any of these answers is unknown, resolve that gap first, since it will drive the rest of the configuration.

Configuration options and when each fits

This table compares the settings that connect Odoo to a PostgreSQL server on another machine, from the server-side network and authentication rules to the Odoo options and the role model. Read each row for the situation where it applies, the trade-off it brings, and what to check in your own environment before you change it.

OptionWhen it fitsTrade-offWhat to confirm
listen_addresses (postgresql.conf)When Odoo app servers connect over the network instead of a local socketWidening the listening address exposes the database port to every network that can route to itWhich interfaces are bound, and that only the application subnet can reach the port
pg_hba.conf host rulesWhen each app server or subnet needs an explicit, authenticated entryBroad CIDR ranges are easy to write and hard to audit laterThat rules match the Odoo hosts only, the auth method used, and the file reloaded after edits
db_host and db_portWhen the database runs on its own machine or a managed endpointA failover or IP change breaks workers until the value is updatedThe default values in the Odoo configuration docs for your version, and the address your DNS resolves to
db_user and db_passwordWhen Odoo connects with a dedicated, non-superuser roleThe password lives in odoo.conf or the environment, so file permissions matterWho can read the config file, and whether the secret is managed outside the file
db_sslmodeWhen traffic crosses networks you do not fully control, or policy requires encryption in transitCertificate verification adds setup work and can fail on private certificate authoritiesWhich modes your Odoo and PostgreSQL versions support, and the certificate chain the client trusts
Database role and ownershipWhen Odoo's role should create and own its databases without superuser rightsOwnership by a shared role can let other applications change the same databasesWhether the role is non-superuser, who owns each database, and that the Odoo role has no unneeded privileges
Connection limits for multiple workersWhen several workers, cron jobs and multiple databases open connections at onceLimits set too low cause connection errors under load; too high uses server memoryWorker and cron counts in your config, the PostgreSQL max_connections value, and pooling needs

Setup sequence for the split database tier

This sequence moves PostgreSQL to its own host, lets only the Odoo application host connect, and points Odoo at the new database with a role that cannot administer the server. Each step closes with a check so a failure is found before Odoo goes live on the new layout.

  1. Confirm network path between the hosts

    The network or cloud team confirms that the Odoo application host can reach the database host on the PostgreSQL port (5432 unless your environment uses another) and that firewall rules allow only that source address. Record both host addresses and the subnet they sit in, because the access rules in later steps depend on them. Done means a basic connectivity test from the application host to the database port succeeds, while the same test from an unrelated host is blocked.

  2. Set listen_addresses on the database host

    A PostgreSQL administrator edits postgresql.conf on the database host and sets listen_addresses so the server listens on the private interface that the application host uses, rather than only on localhost. The change is applied with a service restart in a later step, so nothing is reloaded yet. Done means the file holds the intended value and the administrator has noted the previous setting so it can be reverted.

  3. Add scoped pg_hba.conf entries

    The administrator adds host-based authentication lines in pg_hba.conf that match the Odoo application host address (a single /32 address or a narrow subnet) and the database role created in the next step, using password-based authentication over SSL where your PostgreSQL version and policy support it. Entries should not open access to all databases or all users. Done means the file contains only the Odoo rule plus your existing administrative rules, and the administrator has reviewed the order of entries because PostgreSQL applies the first match.

  4. Create the Odoo role and owner role

    The database administrator creates two roles: a login role for Odoo with no superuser attribute and CREATEDB only if your Odoo workflow requires it (for example, database creation through the database manager), and a separate owner role that owns the Odoo databases. Keeping ownership with a different role limits what the running application can change at the schema level. Done means a query of pg_roles shows the expected attributes, with rolsuper false for the Odoo login role.

  5. Create databases owned by the owner role

    The administrator creates each Odoo database with the owner role as its owner and grants the Odoo login role the access it needs. Database names should match what the Odoo configuration will reference. Done means a listing of databases shows the correct owner for each one, and a connection test from the database host as the Odoo login role succeeds for the Odoo database only.

  6. Set db_host and db_sslmode in odoo.conf

    The Odoo administrator edits odoo.conf on the application host to set db_host to the database host address, db_port if it is not the default, db_user to the Odoo login role, and db_sslmode to the mode your certificates support. The password should come from a protected file or environment mechanism, not a world-readable configuration file. Done means the file parses and the values match the database host, role and SSL decisions recorded earlier.

  7. Restart services and verify from the app host

    The administrator restarts PostgreSQL so listen_addresses takes effect, then restarts the Odoo service on the application host. Before opening Odoo in a browser, the admin runs psql from the application host using the Odoo login role and the database name to confirm the connection path and SSL mode. Done means psql returns a prompt, Odoo starts without database errors in its log, and you can sign in to the Odoo database with a test user.

  8. Check the server log for rejected connections

    After sign-in succeeds, the administrator reviews the PostgreSQL server log for authentication failures or rejected connection attempts from addresses other than the Odoo host, and confirms that the Odoo connection itself is logged as expected. Any rejection from an unexpected address needs a firewall or pg_hba.conf review before the environment is used. Done means the log shows only the expected connections over the test period and the team has recorded the result alongside the configuration change.

How connection limits interact with multi-worker Odoo

Connection limits decide whether a split database tier holds up under load, so size them before the cutover. Each Odoo worker process opens its own connections to PostgreSQL, and the number of workers set in odoo.conf (the workers key) is the main driver of that demand. Cron workers count too, because scheduled actions run in their own processes and hold connections while they work. On a single host, a connection pool misconfiguration often surfaces as slow pages on the same machine. After the split, the same mistake shows up as refused connections from a database server that now has no local context, so the failure is harder to diagnose.

On the database side, check max_connections in postgresql.conf against the total the application tier can open at peak, plus headroom for administrative sessions, backups and monitoring. Reserve a few slots for superuser and maintenance access so you can still log in when the application tier saturates. Remember that max_connections is a server-wide ceiling shared by every application that uses the cluster, so a second Odoo instance or a reporting tool on the same server reduces what Odoo can use. Confirm the per-worker connection behavior and the sizing guidance against Odoo's worker documentation for your version, and confirm the sizing formula against your own load tests rather than a rule of thumb.

Test the limit under realistic concurrency before go-live, and watch the connection count during month-end runs, imports and scheduled jobs, since these are the peaks that exhaust a pool. Record the active connections per database role, the wait time for new connections and any too many clients errors in the PostgreSQL log. Plan a change control step for raising workers or max_connections, because each increase must be matched by memory and a review of the server's limits. Ask your partner or internal team to show the load test results and the chosen values in writing as part of the handover.

Split patterns by environment

On a dedicated Linux VM or physical server, you control the PostgreSQL configuration files directly. Odoo connects over TCP, so the database host must listen on a network interface other than loopback and must accept connections from the Odoo host in pg_hba.conf. Set listen_addresses in postgresql.conf to the interface address, not * unless a firewall restricts it, then add a hostssl or host line that names the Odoo server's address, the database role and the target databases. On the Odoo server, set db_host in odoo.conf to the database host and db_sslmode to a value that matches the certificate setup you chose.

  • Listen address: Change listen_addresses in postgresql.conf, then restart PostgreSQL, since this setting does not reload.
  • Host-based access rule: Add a pg_hba.conf entry scoped to the Odoo server's IP and to the specific Odoo role, not to all.
  • Firewall: Open the PostgreSQL port only from the Odoo server, and only on the interface that carries database traffic.
  • SSL mode: Choose db_sslmode deliberately, and confirm the certificate chain on both ends before setting verify-full.
  • Reload behavior: Reload PostgreSQL after pg_hba.conf edits and test the connection with the Odoo role from the Odoo host before restarting Odoo.

Confirm the PostgreSQL major version, the operating system firewall tool and whether your security team requires certificate-based verification for database connections.

How the Odoo host, workers and database tier connect

The diagram starts with users reaching a reverse proxy on the application side of the network. The proxy hands traffic to the Odoo host, which runs HTTP workers, longpolling workers and cron jobs, each connecting to PostgreSQL through the db_host and db_sslmode options. The network boundary marks where the database tier begins, and the pg_hba.conf gate decides which client addresses and roles may connect. Check that the database rules admit only the application host, that the application role is not a superuser, and that the owner role is kept separate from it.

Odoo processes connect to a separate PostgreSQL host through one gated network boundary.

Security controls for the database tier

Once PostgreSQL runs on its own server, the network path between Odoo and the database becomes an attack surface that did not exist on a single host. The six controls below cover who can connect, how the connection is protected, which role Odoo uses, and how the password and failed attempts are handled.

Restrict pg_hba.conf to the application host

The pg_hba.conf file decides which hosts, users and databases PostgreSQL accepts. Replace broad address ranges with the single address of the Odoo server, and bind each rule to the Odoo role and the databases it needs. Review the file after every change, because a permissive line added during troubleshooting often stays in place. Confirm the rules with the PostgreSQL version you run, since authentication method options differ between releases.

Odoo source install docs

Enforce TLS with db_sslmode

Set db_sslmode in odoo.conf to a value that requires encryption, and configure the PostgreSQL server with a certificate it trusts. Traffic between the two servers may cross a shared network, so unencrypted sessions expose credentials and business data. Decide which verification level your security team accepts, and confirm that the Odoo host trusts the certificate authority that signed the server certificate. Test the connection after each certificate renewal.

Separate the login role from the owner role

Create one role that owns the Odoo databases and a second, non-superuser role that Odoo uses to connect. The login role receives only the privileges the application needs, so a compromised Odoo process cannot drop tables, change ownership or act as a superuser. Keep the owner role unused by the running service. Confirm with your team which role runs schema upgrades, since upgrades may need owner-level rights that the daily login role should not hold.

Limit exposure of port 5432

PostgreSQL listens on port 5432 by default. Set listen_addresses so the server only listens on the interface used by the Odoo host, not on every interface. Then allow the port only from the Odoo server in the host firewall and in any cloud security group or data center network policy. Check that no monitoring tool, backup agent or administrator workstation reaches the port unless it has a documented reason to.

Protect the password in odoo.conf

The db_password value in odoo.conf grants access to every database the role can reach. Set the file owner to the service account that runs Odoo, and restrict permissions so other local users cannot read it. Keep the file out of version control and out of shared backup locations that are widely readable. Plan a rotation procedure that updates the PostgreSQL role and the configuration file in the same change window.

Audit failed connection attempts

Repeated authentication failures can reveal a misconfigured application, a stale password after rotation or an attempted intrusion. Enable connection and authentication logging on the PostgreSQL server, and forward those logs to a system your security team reviews. Decide who receives alerts, how long logs are kept, and which failures trigger a response. Verify that logging works by making a deliberate failed login from a test host.

Questions teams ask before splitting PostgreSQL from Odoo

What does it cost to move PostgreSQL onto a separate server for Odoo?

No price is published for this work, and the cost depends on the scope you agree before the work starts. The main cost components are the time of whoever changes the database host, the network and firewall work between the Odoo and database tiers, the test runs against a copy of your production database, and the new server or virtual machine itself. Some of these are one-time (the change, the testing, the documentation) and some recur (the database server, its backups and its patching). Costs rise with the number of Odoo databases, the number of Odoo servers that connect to the database, the TLS requirements between tiers and how many environments you need to test. Ask any quote to list each component separately, state who performs it, and say which items are one-time and which are ongoing.

How long does a PostgreSQL split take for an Odoo installation?

The duration depends mainly on how many environments must be changed and tested, how much network and security review the new connection needs, and how long a restore of your largest database takes on the new host. A single production database with one application server is a smaller job than several databases shared across production, staging and development. Ask for a timeline that separates the planning, the change window, the test period on a copy and the rollback plan, because the test period is usually the part that varies most. Confirm the window with your own change process, since many organizations require a formal approval before a database host changes.

What does our internal team need to provide for this work?

Your team needs to provide access to the current Odoo and PostgreSQL servers, the odoo.conf file in use, the list of Odoo databases and their sizes, and the network rules between the application and database hosts. Someone must also approve the firewall and certificate changes, confirm the backup schedule and name a person who can accept the test results. Plan for a named business owner to check that key screens, reports and scheduled actions work on the copy before go-live. Without these inputs the work stalls, so confirm them in the scope before the engineer starts.

Can one in-house administrator split PostgreSQL from Odoo alone?

An experienced administrator who already runs PostgreSQL and Odoo can often do the work alone, provided they have a test copy, a rollback path and time to check the results. The risk grows when the same person also owns the network, the certificates and the Odoo application, because a mistake in any one of them can look like a database fault. Consider whether anyone else can review the pg_hba.conf change and the connection settings, and whether there is cover if the administrator is unavailable during the change window. A partner can take the planning, the change and the verification as a fixed scope, or review your own work before go-live.

Can we test a PostgreSQL split on a copy of our Odoo database first?

Yes, and you should, because the change touches authentication and connection settings that every Odoo worker uses. A copy of the database can be restored to a separate database host with the same role layout, and the Odoo configuration can be pointed at it to check that logins, reports, attachments and scheduled actions still work. Odoo's documentation describes database duplication with neutralization for test copies, which keeps live emails and payment settings from firing on the test system. Test the connection limits under realistic worker load, not only a single login, and record the results before you schedule the production change.

Does splitting the database change our Odoo upgrade or support obligations?

The split does not change which Odoo version you run or the dates on which it stops receiving support, but it does add a server to the upgrade plan. Odoo's standard support covers the first three years after a major release, and major upgrades are mandatory every two years on Odoo Online and Odoo.sh. On-premise upgrades through the upgrade service require an Enterprise subscription, and the Community edition has no access to that service. Any upgrade must now also account for the PostgreSQL host, its major version and the restored test database. Confirm the support window of your Odoo version and the upgrade route for your edition before you change the architecture.

When is it worth bringing in a partner to split PostgreSQL from Odoo?

A partner is worth considering when the database holds several companies or environments, when the change must pass a formal compliance or change review, or when the internal team lacks time or experience with PostgreSQL authentication and TLS. It is also useful when you want the work defined as a fixed scope with a written test plan, a rollback plan and verification evidence. DeployOpen implements and hardens self-hosted open-source platforms inside your own infrastructure and prepares the evidence a compliance assessment may request, but it does not issue audit reports or certifications. Ask any partner to show how they will test the split, who will own the change and what they will hand over at the end.

How DeployOpen scopes and delivers a split database tier

DeployOpen is a Chainscore Labs company that plans, implements, hardens, backs up and documents self-hosted open-source platforms inside the client's own infrastructure, including their cloud accounts, data centers or air-gapped networks. For a split database tier, that means the Odoo application servers and the PostgreSQL server are designed together, built in the environment you already run, and handed over with the configuration, runbooks and evidence your own team needs to operate them. The work does not begin with edits to pg_hba.conf or listen_addresses. It begins with a review of the current host, network and capacity, because the answers decide which changes are needed.

The review usually covers the following: where Odoo and PostgreSQL run today and what sits between them, which firewall rules, VLANs or security groups separate the tiers, how many Odoo workers are configured and how many connections they can open at peak, whether the database needs TLS on the wire, and who holds the database administrator role. The output is a written scope that names each change, the systems it touches, the test steps and the cutover window, along with the deliverables and timeline agreed before work starts. Engagements are fixed-scope, so you know what is included and what is a separate change request. Ask for the same breakdown from any partner you evaluate, including which parts depend on your network team or your change board.

Once the split is live, operations do not stop. DeployOpen offers ongoing support, upgrades and continuous testing as retainers, which suits teams that want someone to review connection limits after user growth, rotate database credentials, test restores and apply PostgreSQL and Odoo updates on a schedule. Confirm with any provider which of these recur, who holds the on-call duty and how changes are recorded. A retainer is not a substitute for the written scope, so agree in writing what the retainer covers before you sign it.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.