Parameter · Replication / Sending Servers
max_replication_slots
Sets the maximum number of simultaneously defined replication slots.
- Default:
10 - Type: integer
- Range: 0 … 262143
- Applies: Restart required
In plain words
A replication slot is a bookmark that makes the primary keep WAL (and, for logical slots, old catalog rows) until a particular standby or subscriber has consumed it. max_replication_slots is how many such bookmarks can exist at once, active or not.
Running out is easy to fix with a restart, but an abandoned slot is the real danger: it keeps WAL forever and can fill the disk.
For DBAs and operators
The limit counts all slots in pg_replication_slots: physical, logical, temporary, and synced failover slots on a standby. Creating one more fails with:
ERROR: all replication slots are in use
HINT: Free one or increase "max_replication_slots".
Each logical subscription uses one slot on the publisher, plus additional ones during initial table synchronization (up to max_sync_workers_per_subscription extra per subscription), so size it generously on publishers. On a subscriber, PostgreSQL 17 and earlier also used this value to size replication origins; since 18 that is max_active_replication_origins.
Watch for unused slots
SELECT slot_name, slot_type, active, wal_status, inactive_since,
pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) AS retained
FROM pg_replication_slots;An inactive slot retains WAL without limit unless max_slot_wal_keep_size or idle_replication_slot_timeout is set. A logical slot also holds back catalog_xmin, which blocks vacuum of system catalogs. Drop slots you no longer need with pg_drop_replication_slot().
How to change it
Change in postgresql.conf or ALTER SYSTEM, then restart the server.
See it in context
Replication slots Logical replication Streaming replication WAL sender Logical decoding and ReorderBuffer
Related parameters
max_wal_senders max_slot_wal_keep_size idle_replication_slot_timeout max_active_replication_origins