# query_timeout

Source: https://capacms.com/docs/errors/query_timeout

504 api_error. The database stopped the query at the statement timeout.

| HTTP status | `type`      | Surfaces      |
| ----------- | ----------- | ------------- |
| 504         | `api_error` | REST, GraphQL |

## What it means

The database stopped the query at the statement timeout. Later root fields were not run.

| When                                                                  | What the `hint` tells you                                                          |
| --------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| the read hit the server-side statement timeout (5 seconds by default) | narrow the filter, expand fewer relations or request a smaller `limit`, then retry |

## What to do

Ask for fewer entries or fewer nested relations, or filter on fewer relation hops.

## The response

HTTP 504:

```json
{
  "error": {
    "type": "api_error",
    "code": "query_timeout",
    "message": "The query took too long.",
    "docs": "https://docs.capacms.com/errors/query_timeout"
  },
  "meta": {
    "version": "2026-10-01",
    "contract": 1,
    "requestId": "req_0f3c…"
  }
}
```

## On GraphQL

`/api/graphql` answers the same `code` inside `errors[].extensions`. The status depends on the `Accept` header you send ([status codes](https://capacms.com/docs/api/graphql#status-codes)):

| `application/json` | `graphql-response+json` | When                                                                             |
| ------------------ | ----------------------- | -------------------------------------------------------------------------------- |
| 200                | 200                     | a root field hit the statement timeout; it and every later root field are `null` |

## See also

* [Limits](https://capacms.com/docs/api/limits)
