# Global Timeouts

**Global Timeouts** set the global server timeouts for HTTP request and response streams.

You can set also set [route-level timeouts](https://www.pomerium.com/docs/reference/routes/timeouts.md).

## Timeout Flow Overview

The following diagram shows how different timeouts apply throughout the request lifecycle:

```mermaid
sequenceDiagram
    participant Client
    participant Pomerium
    participant Backend (Upstream)
    Client->>Pomerium: HTTP Request (from client)
    Note over Client,Pomerium: Read Timeout starts when request begins
    Pomerium->>Backend (Upstream): Forward request to upstream<br/>(once request is fully received)
    Note over Pomerium,Backend (Upstream): Default Upstream Timeout starts<br/>after full request is received
    Backend (Upstream)-->>Pomerium: Upstream Response
    Pomerium-->>Client: HTTP Response (to client)
    Note over Pomerium,Client: Write Timeout covers<br/>entire request+response stream
    Note right of Pomerium: Idle Timeout closes idle connections<br/>with no active requests
```

## Timeout Settings Overview

| **Timeout** | **Direction** | **Default** | **Purpose** |
| --- | --- | --- | --- |
| **Read Timeout** | Downstream | 30s | Time allowed to receive complete request from client |
| **Write Timeout** | Downstream | 0 (disabled) | Total time for entire request/response cycle |
| **Idle Timeout** | Bidirectional | 5m | Closes inactive connections when idle |
| **Default Upstream Timeout** | Upstream | 30s | Time allowed for backend to respond |

## Read Timeout

**Read Timeout** sets the maximum duration allowed for the entire downstream HTTP request to be received. This timeout starts when the downstream client initiates the request and ends when Pomerium has fully received the complete request (including headers and body) from the client.

Setting this timeout to `0` disables it. (This is not recommended, as it could allow malicious clients to consume resources with slow or incomplete requests.)

### How to configure

**Core:**

| **Config file keys** | **Environment variables** | **Type** | **Default** |
| :-- | :-- | :-- | :-- |
| `timeout_read` | `TIMEOUT_READ` | [Go Duration] string | `30s` |

### Examples

```yaml
timeout_read: 30s
```

```bash
TIMEOUT_READ=30s
```

**Enterprise:**

**Kubernetes:**

| **[Parameter name](https://www.pomerium.com/docs/deploy/k8s/reference.md#timeouts)** | **Type** | **Defaults** |
| :-- | :-- | :-- |
| `timeouts.read` | [Go Duration] string | `30s` |

### Examples

```yaml
timeouts:
  read: 30s
```

## Write Timeout

**Write Timeout** sets the maximum duration allowed for an entire HTTP request/response cycle to complete. This includes both the time to receive the request from the downstream client and the time to send the complete response back. This timeout should be greater than the [**Read Timeout**](#read-timeout) setting as it encompasses the entire request/response lifecycle.

Setting this timeout to `0` disables it, meaning there is no time limit for request/response completion.

### How to configure

**Core:**

| **Config file keys** | **Environment variables** | **Type** | **Default** |
| :-- | :-- | :-- | :-- |
| `timeout_write` | `TIMEOUT_WRITE` | [Go Duration] string | `0` (no timeout) |

### Examples

```yaml
timeout_write: 0
```

```bash
TIMEOUT_WRITE=0
```

**Enterprise:**

**Kubernetes:**

| **[Parameter name](https://www.pomerium.com/docs/deploy/k8s/reference.md#timeouts)** | **Type** | **Default** |
| :-- | :-- | :-- |
| `timeouts.write` | [Go Duration] string | `0` (no timeout) |

### Examples

```yaml
timeouts:
  write: 0
```

## Idle Timeout

**Idle Timeout** sets the duration after which an upstream or downstream connection will be terminated if there are no active requests or responses.

Setting this timeout to `0` disables it, allowing connections to remain open indefinitely when idle.

### How to configure

**Core:**

| **Config file keys** | **Environment variables** | **Type** | **Default** |
| :-- | :-- | :-- | :-- |
| `timeout_idle` | `TIMEOUT_IDLE` | [Go Duration] string | `5m` |

### Examples

```yaml
timeout_idle: 5m
```

```bash
TIMEOUT_IDLE=5m
```

**Enterprise:**

**Kubernetes:**

| **[Parameter name](https://www.pomerium.com/docs/deploy/k8s/reference.md#timeouts)** | **Type** | **Default** |
| :-- | :-- | :-- |
| `timeouts.idle` | [Go Duration] string | `5m` |

### Examples

```yaml
timeouts:
  idle: 5m
```

## Default Upstream Timeout

**Default Upstream Timeout** is the default timeout applied to a proxied route when no `timeout` key is specified by the policy.

### How to configure

**Core:**

| **Config file keys** | **Environment variables** | **Type** | **Default** |
| :-- | :-- | :-- | :-- |
| `default_upstream_timeout` | `DEFAULT_UPSTREAM_TIMEOUT` | [Go Duration] string | `30s` |

### Examples

```yaml
default_upstream_timeout: 30s
```

```bash
DEFAULT_UPSTREAM_TIMEOUT=1h45m
```

**Enterprise:**

Set **Default Upstream Timeout** in the Console:

\[Enterprise Console with default timeout setting]

**Kubernetes:**

Kubernetes does not support `default_upstream_timeout`

[go duration]: https://golang.org/pkg/time/#Duration.String
