# too many clients are connected

## Symptoms

* Log messages around the central topic of `too many clients are connected`
* Even panic and tracebacks may appear in the logs / output of fylr, like: (shortened here)

```
ERR Recover from panic, rolling back error="could not start read transaction: [...]
/usr/local/go/src/runtime/debug/stack.go:24 +0x5e
runtime/debug.PrintStack()
[...]
/usr/local/go/src/net/http/server.go:3086 +0x5cb
```

## Cause

There are already more connections from fylr to the PostgreSQL database service than the configured limit in PostgreSQL.

## Solution

We recommend to set the limits in fylr and postgres to the same number.

An example can bee seen here: <https://github.com/programmfabrik/fylr-gitbook/commit/ede6fc41a74e1c6963b376b92c45c626eb1f6126>

You may also need to find the correct limit for your situation.

### Change limit in fylr

In fylr yaml configuration: `fylr.db.maxOpenConns`

* If you use this, fylr will try to stay below the new limit and the errors may go away.
* If you use a limit far below what your hardware can handle, you may slow fylr down.

### Change limit in PostgreSQL

* If you increase this limit, the error might go away or appear less frequent.
* But PostgreSQL may consume more memory.
* In [docker-compose.yml](https://github.com/programmfabrik/fylr-gitbook/blob/main/_assets/docker-compose.yml#L35) add a line like `-c max_connections=200` . 200 is just an example. The line shall be below the [line](https://github.com/programmfabrik/fylr-gitbook/blob/main/_assets/docker-compose.yml#L35) with `command` for the postgresql service. The default seems to be 100.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fylr.io/for-system-administrators/symptom-and-solution/too-many-clients-are-connected.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
