How to fix Quay psycopg2.ProgrammingError: invalid dsn: invalid connection option 'keepalivescount'

Problem

When starting up the quay container registry, you see the following error message:

Traceback (most recent call last):
  File "/app/lib/python3.9/site-packages/peewee.py", line 2993, in connect
    self._state.set_connection(self._connect())
  File "/app/lib/python3.9/site-packages/peewee.py", line 3688, in _connect
    conn = psycopg2.connect(database=self.database, **self.connect_params)
  File "/app/lib/python3.9/site-packages/psycopg2/__init__.py", line 121, in connect
    dsn = _ext.make_dsn(dsn, **kwargs)
  File "/app/lib/python3.9/site-packages/psycopg2/extensions.py", line 167, in make_dsn
    parse_dsn(dsn)
psycopg2.ProgrammingError: invalid dsn: invalid connection option "keepalivescount"

Solution

In your config file (config.yaml), you’ll find a section auto-generated by the config generator.

DB_CONNECTION_ARGS:
    keepalives: 0
    keepalivescount: 0
    keepalivesidle: 0
    keepalivesinterval: 0
    sslcompression: 0
    tcpusertimeout: 0

This section causes the error for a reason unknown to me.

Since typically these settings are not required anyway, replace it by

DB_CONNECTION_ARGS: {}

and restart quay.