The problem: Odoo works locally but fails behind Nginx
You set up Odoo on a server and tested it at http://localhost:8069. Everything felt fast and reliable. Then you put Nginx in front as a reverse proxy so users could reach Odoo via https://odoo.yourcompany.com. Now pages load slowly, some actions time out, or users get error messages like Bad Gateway 502 or Connection reset.
These symptoms point to a mismatch between how Odoo expects to be accessed and how Nginx forwards requests. The most common cause is a reverse proxy misconfiguration that breaks Odoo’s built-in URL generation, session handling, or long-polling connections.
Who is affected: End users trying to log in, open forms, or save records; operations staff seeing high response times or failed requests; junior engineers asked to fix "the proxy problem."
What is at risk: Lost productivity, frustrated users, stalled projects, and potential data loss if forms fail to save.
This article focuses on the single most common misconfiguration: Nginx not forwarding the original host and protocol information to Odoo. Fixing this resolves most slowdowns and 502 errors behind Nginx.
Root cause: How Nginx breaks Odoo’s expectations
Odoo builds every URL it returns based on the Host header it receives from the client. When Nginx acts as a reverse proxy, it forwards requests to Odoo with its own host and port, not the original client’s. Odoo then generates links like https://nginx-server:8069/web instead of https://odoo.yourcompany.com/web. This confuses browsers, breaks sessions, and causes timeouts.
Additionally, Odoo uses long-polling for real-time updates (e.g., chat, notifications). Nginx must allow and forward WebSocket connections (ws:// and wss://). If WebSocket support is missing, users won’t get real-time updates and may experience hangs.
The fix is to tell Nginx to forward the original Host header and the connection protocol (HTTP vs HTTPS) to Odoo. Without this, Odoo cannot generate correct URLs or maintain stable sessions.
Key terms:
- Reverse proxy: A server that sits between clients and your Odoo instance, forwarding requests and responses.
- Host header: The
Host: odoo.yourcompany.comline sent by the browser to tell the server which website it wants. - Long-polling: A technique Odoo uses to push updates to users without constant polling.
- WebSocket: A protocol for real-time, two-way communication between browser and server.
Quick checks: Did you set up the proxy correctly?
Before diving into logs or commands, perform these quick checks to see if your proxy matches Odoo’s needs.
Check 1: Does Nginx forward the original Host header?
Open your Nginx configuration file (usually at /etc/nginx/sites-available/odoo.conf or /etc/nginx/conf.d/odoo.conf). Look for a proxy_set_header line for Host.
proxy_set_header Host $host;
What it does: Tells Nginx to forward the original Host header from the browser to Odoo.
Success: The line proxy_set_header Host $host; exists and is uncommented.
Check 2: Is the X-Forwarded-Proto header set?
Odoo needs to know if the original connection was HTTPS so it can generate secure URLs. Look for:
proxy_set_header X-Forwarded-Proto $scheme;
What it does: Tells Odoo whether the user accessed the site via HTTP or HTTPS.
Success: The line proxy_set_header X-Forwarded-Proto $scheme; exists and is uncommented.
Check 3: Are WebSocket connections allowed?
Look for these lines in your Nginx configuration under the Odoo location block:
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
What it does: Enables WebSocket support for real-time features in Odoo.
Success: All three lines exist and are uncommented.
Check 4: Is the Odoo server address correct?
Verify that your proxy_pass line points to your Odoo instance’s correct address and port. For example:
proxy_pass http://localhost:8069;
What it does: Forwards requests from Nginx to the Odoo server.
Success: The address matches your Odoo instance (e.g., localhost:8069, 127.0.0.1:8069, or a remote IP if needed).
If any of these checks fail, you’ve likely found the root cause. Fix the missing or incorrect lines, then reload Nginx. If all checks pass, move to the advanced diagnosis section.
Advanced diagnosis: Symptoms and verification
If the quick checks passed but Odoo is still slow or broken, use these steps to isolate the issue.
Symptom 1: Users see "Bad Gateway 502" errors
This error means Nginx cannot communicate with Odoo. Common causes:
- Odoo is not running or crashed.
- Nginx is pointing to the wrong port or address.
- Firewall or security group is blocking the port.
How to verify:
- Check if Odoo is running:
systemctl status odooWhat it does: Shows whether the Odoo service is active.
Success: Output shows
active (running). - Test direct access to Odoo:
curl http://localhost:8069/webWhat it does: Checks if Odoo responds directly on the server.
Success: Output shows HTML for the Odoo login page.
- Check Nginx error logs:
tail -n 50 /var/log/nginx/error.logWhat it does: Shows Nginx-side errors when forwarding requests.
Success: No
502 Bad Gatewayentries in the last 50 lines.
Symptom 2: Pages load slowly or time out
Slow loads are often caused by:
- Missing or incorrect
X-Forwarded-Forheader, which Odoo uses for rate limiting and logging. - Large file uploads or reports timing out due to Nginx timeouts.
- Odoo worker threads being overwhelmed.
How to verify:
- Check Odoo logs for slow queries or high CPU:
tail -n 100 /var/log/odoo/odoo-server.logWhat it does: Shows Odoo-side performance and errors.
Success: No repeated
TimeoutorWorker timeouterrors. - Check Nginx timeouts in your configuration:
grep timeout /etc/nginx/nginx.confWhat it does: Shows Nginx timeouts for client, proxy, and fastcgi.
For Odoo, set these timeouts in your Nginx server block:
proxy_connect_timeout 60s; proxy_send_timeout 60s; proxy_read_timeout 60s;Success: All timeouts are set to at least 60 seconds.
Symptom 3: Real-time features fail (chat, notifications)
If chat or notifications don’t update, WebSocket connections are likely blocked.
How to verify:
- Open browser developer tools (F12) and check the Network tab.
- Look for a WebSocket connection to
wss://odoo.yourcompany.com/longpolling/.../websocket. - If it shows
400 Bad Requestor404 Not Found, WebSocket support is missing or misconfigured.
Fix: Ensure the WebSocket upgrade headers are present in your Nginx configuration, as shown in the quick checks.
Fix: Apply the proxy settings and test
Use this checklist to update your Nginx configuration and apply the fix.
Step 1: Edit your Nginx configuration
Open the file for your Odoo site:
sudo nano /etc/nginx/sites-available/odoo.conf
What it does: Opens the configuration file for editing.
Step 2: Add or correct proxy headers
Inside your server block, under the location / block, add or correct these lines:
location / {
proxy_pass http://localhost:8069;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
What it does: Forwards original client information to Odoo and enables WebSocket support.
Step 3: Set appropriate timeouts
Add these lines in the http block of your Nginx config (or in the server block):
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
What it does: Prevents Nginx from closing connections too early during slow operations or large uploads.
Step 4: Test and reload Nginx
Check your configuration for syntax errors:
sudo nginx -t
What it does: Validates the Nginx configuration before applying changes.
Success: Output shows syntax is ok and test is successful.
If the test passes, reload Nginx:
sudo systemctl reload nginx
What it does: Applies the new configuration without dropping active connections.
Success: No errors in logs; Odoo is accessible via the proxy.
Step 5: Verify the fix
Perform these checks after reloading:
- Open Odoo in a browser via the proxy URL. Log in and navigate to a form. Check that URLs in the browser match the proxy domain (e.g.,
https://odoo.yourcompany.com/web). - Open developer tools (F12) and check the Network tab. Look for a WebSocket connection to
wss://odoo.yourcompany.com/longpolling/.../websocket. It should show101 Switching Protocols. - Test a file upload or report generation. Ensure it completes without timeouts.
When to seek help: Red flags and escalation
If you’ve applied the fix and Odoo is still slow, broken, or crashing, escalate using these triggers. Do not spend more than 30 minutes troubleshooting alone if any of these occur.
Red flags that require immediate help
- Persistent 502/504 errors after reloading Nginx and verifying Odoo is running.
- Odoo crashes or restarts when users log in or open a form (check
/var/log/odoo/odoo-server.logforMemoryErrororSegmentation fault). - Data loss or corruption (e.g., unsaved form data, missing records).
- Security warnings in browser console (e.g.,
Mixed Content,Invalid Host header). - Odoo is unreachable even on localhost, suggesting a deeper system issue.
What to provide to your support team
Gather these logs and files before contacting support:
- Nginx error log:
sudo tail -n 200 /var/log/nginx/error.log - Odoo server log:
sudo tail -n 200 /var/log/odoo/odoo-server.log - Your Nginx configuration file:
sudo cat /etc/nginx/sites-available/odoo.conf - Odoo configuration file (usually at
/etc/odoo/odoo.conf):sudo cat /etc/odoo/odoo.conf - Browser console errors (F12 > Console tab).
If you’re using a managed Odoo service or a deployment from Odoo Implementation Services, include your deployment ID or instance name.
For custom addons or integrations, note any recently installed modules from Odoo Custom Addons or Odoo Integration. Mention if the issue started after a module update or integration change.
Prevention: Keep your proxy in sync with Odoo
Once fixed, follow these practices to avoid future proxy issues during Odoo updates, migrations, or scaling.
1. Version compatibility checklist
Odoo and Nginx versions can drift. Use this table to check compatibility:
| Odoo Version | Recommended Nginx Version | Key Proxy Settings |
|---|---|---|
| Odoo 15 | Nginx 1.18+ | proxy_http_version 1.1, Upgrade headers |
| Odoo 16 | Nginx 1.20+ | Same as above, plus X-Forwarded-Proto for SSL |
| Odoo 17 | Nginx 1.22+ | All headers, plus proxy_buffering off for reports |
Note: Always test proxy settings after upgrading Odoo. New features may depend on WebSocket or long-polling.
2. Deployment risk: Proxy changes during upgrades
When upgrading Odoo or moving to a new server, update your Nginx configuration before or immediately after the upgrade. Common pitfalls:
- Forgetting to update
proxy_passto point to the new Odoo server address. - Missing
X-Forwarded-Protoafter enabling HTTPS, causing mixed-content warnings. - Disabling WebSocket support during a rollback, breaking real-time features.
Best practice: Include proxy configuration in your deployment runbook. Test the proxy URL before cutting over users.
3. Module development and proxy-aware code
If you develop custom modules for Odoo, make them proxy-aware. Two common issues:
- Absolute URLs in code: Use
request.httprequest.hostinstead of hardcodinglocalhost:8069. - WebSocket endpoints: Ensure your custom long-polling endpoints are accessible via the proxy path.
Example of proxy-safe URL generation in Python:
def get_odoo_url(self, request):
base_url = request.httprequest.host
return f"https://{base_url}/web/image/{self.id}"
What it does: Generates a full URL using the original host from the request, ensuring it works behind a proxy.
4. Monitoring and alerting
Set up basic monitoring to catch proxy issues early:
- Monitor Nginx error logs for 502/504 errors.
- Track Odoo response times via Nginx access logs.
- Alert on repeated login failures or session timeouts.
If you’re on a paid Odoo plan, check Odoo Pricing for monitoring addons or support tiers that include uptime checks.
Summary: What to do first and next
Start with the quick checks. If any line is missing or incorrect, fix it first. Then reload Nginx and test. If Odoo is still broken, escalate using the red flags in the "When to seek help" section.
Immediate action checklist:
- Open your Nginx configuration file.
- Verify
proxy_set_header Host $host;exists. - Verify
proxy_set_header X-Forwarded-Proto $scheme;exists. - Verify WebSocket upgrade headers are present.
- Set Nginx timeouts to at least 60 seconds.
- Run
sudo nginx -tto check syntax. - Reload Nginx with
sudo systemctl reload nginx. - Test Odoo via the proxy URL and check for errors.
If you don’t fix this now: Users will continue to experience slow loads, failed logins, and broken real-time features. The longer the misconfiguration persists, the harder it is to debug, especially if sessions or data become inconsistent.
Fixing this proxy issue is a 15-minute task for most teams. Delaying it risks user frustration and project delays.
Practical Next Step
Check your Nginx reverse proxy settings now
Discuss Your Odoo ScopeFAQ
Why does Odoo generate wrong URLs when behind Nginx?
Odoo builds every URL it returns based on the Host header it receives. When Nginx acts as a reverse proxy, it forwards requests with its own host (e.g., nginx-server:8069), not the original client host (e.g., odoo.yourcompany.com). Without proxy_set_header Host $host;, Odoo generates links like https://nginx-server/web, which break when users click them.
What error messages indicate a proxy misconfiguration?
Common error messages include 502 Bad Gateway, 504 Gateway Timeout, Connection reset, or browser console errors like Mixed Content or Invalid Host header. These usually mean Nginx cannot forward requests correctly to Odoo or Odoo cannot respond due to missing headers or timeouts.
How do I know if WebSocket support is missing?
Open your browser’s developer tools (F12), go to the Network tab, and look for a WebSocket connection to wss://odoo.yourcompany.com/longpolling/.../websocket. If it shows 400 Bad Request or 404 Not Found, WebSocket support is missing. In Nginx, this happens when the upgrade headers (Upgrade $http_upgrade and Connection "upgrade") are missing or commented out.
What Nginx timeouts should I set for Odoo?
Set these three timeouts in your Nginx configuration under the Odoo location block:
proxy_connect_timeout 60s; (time to connect to Odoo),
proxy_send_timeout 60s; (time to send request to Odoo),
proxy_read_timeout 60s; (time to wait for response from Odoo).
These prevent Nginx from closing connections too early during slow operations or large file uploads.
Do I need to update proxy settings after upgrading Odoo?
Yes. New Odoo versions may introduce features that depend on WebSocket or long-polling. Always review your Nginx configuration after upgrading Odoo. Check for proxy_http_version 1.1, WebSocket upgrade headers, and the X-Forwarded-Proto header to ensure HTTPS links are generated correctly.