// postgresql · security & access

ssl

Accept TLS connections on the normal PostgreSQL port.

Predeterminado
off
Range
on, off
Restart needed
No
Default checked on
PostgreSQL 18

Lo que hace

Needs a certificate (ssl_cert_file, default server.crt) and matching private key (ssl_key_file, default server.key), normally in the data directory. Turning ssl on does not force clients to use TLS; a hostssl line in pg_hba.conf does.

Valor predeterminado

off. off (PostgreSQL 18). The official Docker image ships no certificates, so it stays off unless you mount them.

Check the current value

SHOW ssl;

SELECT setting, unit, boot_val, context, source, pending_restart
FROM pg_settings
WHERE name = 'ssl';

Change it

ALTER SYSTEM SET ssl = on;
SELECT pg_reload_conf();

No restart: reload with SELECT pg_reload_conf() or pg_ctl reload. It cannot be changed per session (context is sighup).

When to change it

On any server whose traffic crosses a network you do not control, together with hostssl rules in pg_hba.conf and password_encryption = scram-sha-256.

What can go wrong

A server.key that is not owned by the server's OS user, or readable by group or others, fails the start or the reload with a permission error, and a failed reload keeps the old settings running. With ssl on but no hostssl rules, clients that never ask for TLS keep connecting in the clear.

Questions about ssl

What is the default value of ssl in PostgreSQL?

off. off (PostgreSQL 18). The official Docker image ships no certificates, so it stays off unless you mount them.

Does changing ssl require a restart?

No. No restart: reload with SELECT pg_reload_conf() or pg_ctl reload. It cannot be changed per session (context is sighup).

When should I change ssl?

On any server whose traffic crosses a network you do not control, together with hostssl rules in pg_hba.conf and password_encryption = scram-sha-256.

Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.

// one client for every engine

Check ssl on your own server

SQLly runs the query above against PostgreSQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.

Texto y datos de esta página: CC BY 4.0, con atribución a SQLly (sqlly.app). Código y fragmentos SQL: MIT. Detalles de la licencia