# ssl

> Accept TLS connections on the normal PostgreSQL port.

Source: https://sqlly.app/sql-configuration/postgresql/ssl
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).

**Default**

`off`

**Range**

on, off

**Restart needed**

No

**Default checked on**

PostgreSQL 18

## What it does

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.

## Default value

`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](https://sqlly.app/sql-configuration/postgresql), or check the [PostgreSQL manual](https://www.postgresql.org/docs/current/runtime-config.html) for every option.

## Related PostgreSQL settings

- [`password_encryption` How CREATE ROLE and ALTER ROLE store new passwords: SCRAM-SHA-256 or the legacy MD5 hash.](https://sqlly.app/sql-configuration/postgresql/password-encryption)
- [`listen_addresses` Network interfaces the server accepts TCP connections on.](https://sqlly.app/sql-configuration/postgresql/listen-addresses)
