I started getting a 502 bad gateway on odoo 14 hosted on Digital Ocean, it happens randomly, it doesnt really have any pattern at all.
it happens randomly in some machines that use the service sometimes, some other times the whole services collapses, the only solution is restarting both odoo and nginx services all over again
is worth noticing this odoo has at least 5 databases
in the nginx log im getting the following error:
2023/09/28 15:27:13 [error] 21272#21272: *3214384 connect() failed (111: Connection refused) while connecting to upstream, client: 190.97.228.2, server: sitename.com, request: "POST /longpolling/poll HTTP/1.1", upstream: "http://127.0.0.1:8072/longpolling/poll", host: "mysitename.com", referrer: "http://mysitename.com/ web"
my odoo server conf:
[options] ; This is the password that allows database operations: admin_passwd = QSTSG7DzlrIzUT5N http_port = 8069 logfile = /var/log/odoo/odoo-server.log addons_path=/odoo/odoo-server/addons,/odoo/custom/addons proxy_mode=True
my nginx default config
server { listen 80; # set proper server name after domain set server_name sitename.com www.mysitename.com; # Add Headers for odoo proxy mode proxy_set_header X-Forwarded-Host \$host; proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto \$scheme; proxy_set_header X-Real-IP \$remote_addr; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; proxy_set_header X-Client-IP \$remote_addr; proxy_set_header HTTP_X_FORWARDED_HOST \$remote_addr; # odoo log files access_log /var/log/nginx/odoo-access.log; error_log /var/log/nginx/odoo-error.log; # increase proxy buffer size proxy_buffers 16 64k; proxy_buffer_size 128k; proxy_read_timeout 900s; proxy_connect_timeout 900s; proxy_send_timeout 900s; # force timeouts if the backend dies proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; types { text/less less; text/scss scss; } # enable data compression gzip on; gzip_min_length 1100; gzip_buffers 4 32k; gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript application/pdf image/jpeg image/png; gzip_vary on; client_header_buffer_size 4k; large_client_header_buffers 4 64k; client_max_body_size 0; location / { proxy_pass http://127.0.0.1:8069; # by default, do not forward anything proxy_redirect off; } location /longpolling { proxy_pass http://localhost:8072; } location ~* .(js|css|png|jpg|jpeg|gif|ico)$ { expires 2d; proxy_pass http://127.0.0.1:8069; add_header Cache-Control "public, no-transform"; } # cache some static data in memory for 60mins. location ~ /[a-zA-Z0-9_-]*/static/ { proxy_cache_valid 200 302 60m; proxy_cache_valid 404 1m; proxy_buffering on; expires 864000; proxy_pass http://127.0.0.1:8069; } }