How to fix headscale startup error "failed to configure TLS (sslmode is invalid)"

Problem:

When starting headscale 0.17.0 or newer, you see repeating error messages like

headscale_1  | 2022-11-26T20:03:39Z FTL go/src/headscale/cmd/headscale/cli/server.go:21 > Error initializing error="cannot parse `host=postgres dbname=headscale user=headscale sslmode= port=5432 password=xxxxx`: failed to configure TLS (sslmode is invalid)"

Solution

This error occurs due to a change starting from headscale 0.17.0. In your config.yaml, add

db_ssl: false

after db_type: ...

Complete database section config example:

# # Postgres config
db_type: postgres
db_host: postgres
db_port: 5432
db_name: headscale
db_user: headscale
db_pass: Paep6AhJiZeedie5fiefieV0quohro

db_ssl: false

After that, restart headscale and the error message should disappear.