Dev.to WebDev 🛠 Dev 👁 0 📖 1 min read

How to Fix Dropped Odoo and WSS WebSocket Connections in Nginx

If Odoo live chat, discuss notifications, or bus polling keep disconnecting behind an Nginx reverse proxy, two config mistakes are usually responsible: Routing /websocket to Odoo's main HTTP port (8069) instead of its

If Odoo live chat, discuss notifications, or bus polling keep disconnecting behind an Nginx reverse proxy, two config mistakes are usually responsible:

  1. Routing /websocket to Odoo's main HTTP port (8069) instead of its evented gevent port (8072).
  2. Leaving Nginx's default proxy_read_timeout at 60 seconds without HTTP/1.1 upgrade headers.

The Broken Pattern

A standard reverse proxy block forwards everything to 8069 over HTTP/1.0 and drops idle WebSocket connections every minute:

location / {
    proxy_pass [http://127.0.0.1:8069](http://127.0.0.1:8069);
}

Working Nginx Config for Odoo 16/17+ WebSockets

Define a $connection_upgrade map in your http block so standard HTTP requests keep working alongside WebSocket upgrades:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen 443 ssl http2;
    server_name erp.example.com;

    # Route WebSocket traffic to Odoo gevent port 8072
    location /websocket {
        proxy_pass [http://127.0.0.1:8072](http://127.0.0.1:8072);
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        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_read_timeout 720s;
        proxy_send_timeout 720s;
    }

    # Route standard ERP traffic to port 8069
    location / {
        proxy_pass [http://127.0.0.1:8069](http://127.0.0.1:8069);
        proxy_http_version 1.1;
        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;
    }
}

(Note: If you are still running Odoo 15 or older, change the /websocket location path to /longpolling.)

Test Your Own Nginx Config in the Browser

If you want to customize upstream ports, TLS headers, or general wss:// upgrade rules without uploading your server configs anywhere, I built a client-side simulator for it:

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.