> Markdown version of https://tuna.am/en/docs/troubleshooting/errors/upstream-request-timeout/. Documentation index: [llms.txt](https://tuna.am/en/llms.txt), full text in one file: [llms-full.txt](https://tuna.am/en/llms-full.txt). Any page is available as Markdown: append `.md` to its URL without the trailing slash.

# upstream request timeout

A request to the tunnel hangs without a response for a long time, and then a short plain-text response arrives. The text and status depend on where the timeout fired:

```text
upstream request timeout

```

```text
stream timeout

```

```text
net/http: timeout awaiting response headers

```

## Cause

The service behind the tunnel accepted the request but takes too long to respond. Tuna doesn't hold such a request forever:

* `upstream request timeout`, status `504` — the Tuna edge server didn't see the response start in time. Regular HTTP tunnels may have a one-minute limit on the start of the response. The [file server](https://tuna.am/en/docs/tunnels/http.md#file-server), [WebDAV](https://tuna.am/en/docs/tunnels/http.md#webdav), [1C](https://tuna.am/en/docs/tunnels/1c.md), and [Kubernetes](https://tuna.am/en/docs/tunnels/kubernetes.md) tunnels have no such limit: long responses are normal for them.
* `stream timeout`, status `408` — the service sent not a single byte for 3 hours and never started responding. This is the idle limit of an HTTP tunnel. The total request duration isn't limited: as long as data keeps flowing, the connection stays open.
* `net/http: timeout awaiting response headers`, status `502` — the service of an [app](https://tuna.am/en/docs/apps.md) in proxy mode didn't start responding within 30 seconds. This is the default; you can change it for an app with the `response_timeout` field in the API.

If the connection to the service drops before the response, you may get a `503` with the text `upstream connect error or disconnect/reset before headers` instead of a timeout.

## What to do

1. Check that the service responds locally and doesn't hang on this request: `curl -v http://localhost:3000/path`.
2. Move long operations — report generation, exports, file processing — to the background: respond right away that the job is accepted, and return the result in a separate request.
3. For long streaming responses, send data or the response headers right away rather than at the very end, for example with [Server-sent events](https://tuna.am/en/docs/tunnels/http.md#server-sent-events).

If the tunnel isn't yours and someone sent you the link, retry the request later or contact whoever sent it.
