How to update the NGINX timeout setting for a Magento 2 Cloud Docker setup

How to update the NGINX timeout setting for a Magento 2 Cloud Docker setup

August 25, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to update the NGINX timeout setting for a Magento 2 Cloud Docker setup

Extending Nginx Timeouts for Your Magento Docker Setup

Are you working with Magento 2 and need to adjust the Nginx timeout settings within your local Cloud Docker environment? You’re in the right place! In this guide, we’ll walk through the process of extending the timeouts without having to modify core files.

Why Adjust Nginx Timeouts?

The default Nginx timeouts are set to be quite restrictive by design for performance and security reasons. However, when developing or testing complex functionalities, you might encounter scenarios where these limits are too short.

Locating the Relevant Configuration

The Nginx configuration files in the Magento Docker setup are located under /opt/nginx/conf.d. The main file of interest is default.conf.

Updating the Timeout Settings

The key settings we need to modify are found within the <server> block:

server {
    # ...
    keepalive_timeout 60;
    proxy_read_timeout 60;
    proxy_connect_timeout 60;
    proxy_send_timeout 60;
    # ...
}

By default, all timeouts are set to 60 seconds.

Extending the Timeouts

To increase these values, simply modify the settings within your default.conf file:

server {
    # ...
    keepalive_timeout 120; # Increased from 60 to 120 seconds
    proxy_read_timeout 120;
    proxy_connect_timeout 120;
    proxy_send_timeout 120;
    # ...
}

Deploying the Changes

After updating the file, you can deploy your changes by restarting Nginx within the Docker container:

docker-compose exec nginx nginx -s reload

This command sends a HUP signal to Nginx, which reloads the configuration without dropping any existing connections.

Avoiding Core Modifications

It’s important to note that modifying core files directly is generally discouraged in production environments. Instead, consider using file overrides or environment variables within your docker-compose.yml file for a cleaner and more maintainable setup.

For example, you could add an environment variable to set the timeout value:

services:
  nginx:
    environment:
      - NGINX_KEEPALIVE_TIMEOUT=120

Then, in your default.conf, add conditional logic based on this environment variable. This approach keeps your modifications separate from the core files.

Conclusion

Adjusting Nginx timeouts within a Magento Docker setup is straightforward once you know where to look. By modifying the relevant configuration file or using environment variables, you can easily extend the timeouts without touching core code.

Remember, it’s crucial to be cautious when adjusting timeouts in production environments. Only do so after careful consideration and thorough testing.

For more advanced configuration techniques and best practices with Magento Docker setups, check out our comprehensive guide at Laravel Company.

Magento 2 Performance Security API

Our network