FATAL: too many connections for role "kong"


I’m running Kong in DB mode with Postgres and I’m finding it’s exhausting all my DB connections. My suspicion is that Kong isn’t releasing/closing DB connections properly after it uses them.

I’ve setup a “kong” postgres user that’s the owner of the “kong” database. I set the max_connections for the “kong” PG user to 200. Seems like 200 max connections should be more than enough for an API gateway proxy.

However, frequently Kong is throwing an error like the one below.

2019/10/09 17:54:05 [error] 31#0: *37149566 [kong] init.lua:98 FATAL: too many connections for role “kong”, client:, server: kong_admin, request: “GET /services HTTP/1.1”, host: “localhost:8444”

  1. Is the Kong Admin API the only component that connects to the DB or does Kong ingress controller connect to the DB too?

  2. Assuming Kong is properly closing its DB connections what would you recommend for max_connections? Disabling max_connection on the “kong” DB user results in all PG connection slots being exhausted and my other apps fail to acquire a DB connection because Kong takes all the connection slots.

  3. Is there any other suggestions you’d recommend to resolve this issue?

Have a look at the pg_max_concurrent_queries config value (https://docs.konghq.com/1.3.x/configuration/#postgres-settings); it was implemented exactly for this problem :slight_smile:

1 Like

I tried this config in my test environment, and it does not work

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ