> ## Documentation Index
> Fetch the complete documentation index at: https://www.qovery.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# NGINX timeout: increase the 60 second limit

> Slow requests fail with 504 or 502 when the NGINX ingress gets no response data for 60 seconds. Raise the proxy read, send and connect timeouts of the service, or set the Gateway API request timeout.

A slow request fails when your service sends no response data for 60 seconds, even though the same call works when you run the application locally. The client gets a `504 Gateway Time-out` (sometimes a `502`), and the NGINX logs of the service show:

```text theme={null}
upstream timed out (110: Connection timed out) while reading response header from upstream
```

WebSocket and server-sent event connections that stay quiet for 60 seconds are closed for the same reason.

## Cause

Requests to a public port go through the ingress of the cluster before they reach your service. By default, the NGINX ingress waits at most 60 seconds between two reads of the response from your service, then gives up. This is an inactivity limit, not a limit on the total duration: a response that keeps sending data, such as a stream, can last longer. Your application keeps running, but the client has already received an error.

There is no single "request timeout" field: NGINX has one timeout per step, and each is an advanced setting of the service.

| Advanced setting | What it limits | Default |
| - | - | - |
| [`network.ingress.proxy_read_timeout_seconds`](https://www.qovery.com/docs/configuration/service-advanced-settings#network-ingress-proxy-read-timeout-seconds) | Time to wait between two reads of the response from your service, including the first byte. This is the one that ends slow requests. | `60` |
| [`network.ingress.proxy_send_timeout_seconds`](https://www.qovery.com/docs/configuration/service-advanced-settings#network-ingress-proxy-send-timeout-seconds) | Time to transmit the request to your service, for large uploads. | `60` |
| [`network.ingress.send_timeout_seconds`](https://www.qovery.com/docs/configuration/service-advanced-settings#network-ingress-send-timeout-seconds) | Time to transmit the response to a slow client. | `60` |
| [`network.ingress.proxy_connect_timeout_seconds`](https://www.qovery.com/docs/configuration/service-advanced-settings#network-ingress-proxy-connect-timeout-seconds) | Time to open a connection to your service. Rarely needs a change. | `60` |

## Fix on the NGINX ingress

**1. Open the advanced settings of the service**

In the Console, open the application, container or Helm service, go to **Settings**, then **Advanced Settings**.

**2. Raise the timeouts**

Set `network.ingress.proxy_read_timeout_seconds` to a value above the duration of your longest request, for example `120` or `300`. For long uploads, raise `network.ingress.proxy_send_timeout_seconds` too. For large downloads to slow clients, raise `network.ingress.send_timeout_seconds`.

**3. Redeploy the service**

The new values apply only after the service is redeployed. Saving the settings is not enough.

With the API or Terraform, set the same keys in the advanced settings of the service:

```json theme={null}
{
  "network.ingress.proxy_read_timeout_seconds": 300,
  "network.ingress.proxy_send_timeout_seconds": 300
}
```

## Fix on the Gateway API

When the cluster advanced setting [`k8s.use_api_gateway`](https://www.qovery.com/docs/configuration/cluster-advanced-settings#k8s.use_api_gateway) is `true`, new services are exposed through the Gateway API instead of NGINX. Services created before the switch can still route through NGINX, where the `network.ingress.*` settings above apply. Check how your own service is exposed before changing settings. For a service exposed through the Gateway API, the `network.ingress.*` settings do not apply. Use these instead, then redeploy the service:

* [`network.gateway_api.http_request_timeout_seconds`](https://www.qovery.com/docs/configuration/service-advanced-settings#network-gateway-api-http-request-timeout-seconds): maximum time to wait for the complete response. Requests that take longer end with `504 Gateway Timeout`.
* [`envoy.gateway_api.http_request_timeout_seconds`](https://www.qovery.com/docs/configuration/cluster-advanced-settings#envoy-gateway-api-http-request-timeout-seconds): the cluster-wide default, used by services that do not set their own value.

## Before raising the timeout

A longer timeout keeps a connection and a worker busy for the whole request. For work that takes minutes, consider answering at once and processing in the background: put the job in a queue, return `202 Accepted` with an ID, and let the client poll for the result. A [lifecycle job](https://www.qovery.com/docs/configuration/lifecycle-job.md) or a [cron job](https://www.qovery.com/docs/configuration/cronjob.md) can also run long tasks outside the request path.

If requests fail with `502` well before 60 seconds, the cause is not a timeout. See [502 Bad Gateway: recv() failed (104: Connection reset by peer)](https://www.qovery.com/docs/getting-started/troubleshoot/nginx-502-connection-reset.md).

## Still stuck?

Contact Qovery support from the Console: click the help button at the bottom right, then **Contact Support**. You can also post in your dedicated Slack channel. Include the Console URL of the service, the deployment ID or the time of the error, and the error line from the logs. See [Help and Support](https://www.qovery.com/docs/getting-started/useful-resources/help-and-support.md).


## Related topics

- [502 Bad Gateway: recv() failed (104: Connection reset by peer)](https://www.qovery.com/docs/getting-started/troubleshoot/nginx-502-connection-reset.md)
- [Troubleshooting](https://www.qovery.com/docs/getting-started/troubleshoot/overview.md)
- [Service Advanced Settings](https://www.qovery.com/docs/configuration/service-advanced-settings.md)
- [How to Setup Rate Limit on Services](https://www.qovery.com/docs/getting-started/guides/advanced-tutorials/rate-limiting.md)
- [Edit advanced settings](https://www.qovery.com/docs/api-reference/helm-configuration/edit-advanced-settings.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.