Fix Odoo 504 Gateway Timeout Error

504 Gateway Timeout Error

by Dharmesh Patel

The "504 Gateway Timeout" error in Odoo, or any web application, typically indicates that a server acting as a gateway or proxy did not receive a timely response from an upstream server. This can be due to various reasons including server overload, network issues, or configuration errors. Here are some strategies to resolve this issue:

Odoo Configuration

Adjust Worker Processes

Adjust the number of worker processes based on your server’s capacity. An inappropriate number of workers can lead to performance issues. Assess your server’s capabilities and configure the worker processes accordingly.

Timeout Settings

Timeout settings dictate how long the server waits for a process before timing out. Increase the timeout settings for worker processes in the Odoo configuration file (odoo.conf). For instance:

​limit_time_cpu = 600
limit_time_real = 1200

Optimise Database Connection Pool

Ensure the connection pool is appropriately configured. A well-configured database connection pool can handle multiple database requests efficiently. Ensure your settings are optimised for your server’s capacity and workload.

Web Server Configuration

NGINX/Apache Timeout Settings

Increase the timeout settings in your web server configuration.

For NGINX

If you are using NGINX, increase the timeout settings to allow more time for requests to complete. Adjust the timeout settings as follows:

​proxy_read_timeout 600;
proxy_connect_timeout 600;
proxy_send_timeout 600;

Example NGINX Configuration

server {
    listen 443 SSL;
    server_name www.numla.com numla.com;

    error_log /var/log/nginx/odoo-17/numla-site-error.log;
    access_log /var/log/nginx/odoo-17/numla-site-access.log;
    include includes/odoo_common;

    location / {
                     #proxy_redirect off;
                     proxy_pass http://127.0.0.1:$numla_port;
                     proxy_read_timeout 720s;
                     proxy_connect_timeout 720s;
                     proxy_send_timeout 720s;
                     # 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;
                     proxy_redirect off;
    }

    send_timeout 600s;
    keepalive_timeout 300;
}

For Apache

If you are using Apache, increase the ‘ProxyTimeout’ setting to give your server more time to process requests. Adjust the timeout setting as follows:

​ProxyTimeout 600

By following these steps, you can effectively troubleshoot and resolve the "504 Gateway Timeout" error in Odoo. Properly configuring your Odoo and web server settings ensures a more stable and efficient application, reducing the likelihood of encountering timeout issues.

Need more development tips?

Stay tuned to our blog.

Creating Dynamic Reports in Odoo 17
Handling Auto-Generated Fields in Account Analytic Plans