A restored PostgreSQL server or subscription asks for a replication slot that is gone
Your error
could not start WAL streaming: ERROR: replication slot "standby1" does not exist1 more line it can showFix it fast
Most common cause, 1 of 3The restored backup starts as a standby and names a slot the primary does not have
If the restored server is meant to be a standby, create the physical slot on the primary under the same name.
-- on the primary
SELECT pg_create_physical_replication_slot('standby1');
# or rebuild the standby so slot and backup start together
pg_basebackup -h primary.example.com -D /path/to/new/data -X stream -C -S standby1 -RShort answer
could not start WAL streaming: ERROR: replication slot "name" does not exist means the restored server, or a subscription inside it, asks the upstream server for a slot that is not there. A restored standby inherits primary_slot_name from pg_basebackup -R, and restored subscriptions keep their slot names. Create the slot upstream, or drop the reference. PostgreSQL 15 to 19.
Which cause do you have?
Find out what in the restored data directory is asking for a slot, then compare it with the slots that really exist on the upstream server. A signal file plus primary_slot_name points at a standby setting; a row in pg_subscription points at a subscription.
# on the restored server (data directory)
ls "$PGDATA"/*.signal
grep -n "primary_conninfo\|primary_slot_name" "$PGDATA"/postgresql.auto.conf
-- on the restored server, if it accepts connections
SELECT subname, subslotname, subenabled FROM pg_subscription;
-- on the upstream (primary or publisher)
SELECT slot_name, slot_type, active FROM pg_replication_slots;Then find the line you see in this list and open its fix:
- 1The restored backup starts as a standby and names a slot the primary does not have
standby.signal exists, postgresql.auto.conf sets primary_slot_name, and that name is missing from pg_replication_slots on the primary - 2The restore was meant as a point-in-time copy, but it carries standby settings
You wanted an independent server recovered from the archive, yet the data directory holds standby.signal and primary_conninfo from the backup - 3A restored subscription points at a slot the publisher never had or has dropped
pg_subscription on the restored server lists a subscription whose subslotname matches the name in the error, and the publisher has no such slot
What does the error look like?
could not start WAL streaming: ERROR: replication slot "standby1" does not existERROR: replication slot "sub1" does not exist
Cause 1 of 3
The restored backup starts as a standby and names a slot the primary does not have
You seestandby.signal exists, postgresql.auto.conf sets primary_slot_name, and that name is missing from pg_replication_slots on the primary
Check
This replication slot error on a restored base backup comes from pg_basebackup -R: it writes standby.signal plus the connection settings and, when -S was used, the slot name into postgresql.auto.conf. If that slot was dropped later, or the backup is now pointed at a different primary, the WAL receiver asks for a slot that does not exist.
grep -n "primary_slot_name" "$PGDATA"/postgresql.auto.confFix
If the restored server is meant to be a standby, create the physical slot on the primary under the same name. A slot created now only holds WAL from this moment, so if the standby needs older WAL that the primary already removed, take a fresh base backup with -C -S instead.
-- on the primary
SELECT pg_create_physical_replication_slot('standby1');
# or rebuild the standby so slot and backup start together
pg_basebackup -h primary.example.com -D /path/to/new/data -X stream -C -S standby1 -RVerify
On the primary, the slot shows active = true once the standby streams.
SELECT slot_name, active FROM pg_replication_slots WHERE slot_name = 'standby1';Confirmed by postgresql.org
Cause 2 of 3
The restore was meant as a point-in-time copy, but it carries standby settings
You seeYou wanted an independent server recovered from the archive, yet the data directory holds standby.signal and primary_conninfo from the backup
Check
When the goal is point-in-time recovery, the slot error is a side effect of the server running in standby mode. primary_slot_name has no effect unless primary_conninfo is set and the server is in standby mode, so the fix is to leave standby mode rather than to create a slot.
ls "$PGDATA"/standby.signal
grep -n "restore_command\|recovery_target" "$PGDATA"/postgresql.confFix
Stop the server, remove standby.signal and the two streaming lines from postgresql.auto.conf (edit that file only while the server is down), set restore_command in postgresql.conf, and create recovery.signal before starting.
pg_ctl -D "$PGDATA" stop
rm "$PGDATA"/standby.signal
sed -i '/^primary_conninfo/d; /^primary_slot_name/d' "$PGDATA"/postgresql.auto.conf # GNU sed
# postgresql.conf: restore_command = 'cp /mnt/archive/%f %p' (plus a recovery target if you need one)
touch "$PGDATA"/recovery.signal
pg_ctl -D "$PGDATA" startVerify
The log shows WAL restored from the archive with no streaming attempt; when recovery completes, the server removes recovery.signal and starts normal operation.
psql -c "SELECT pg_is_in_recovery();"Confirmed by postgresql.org
Cause 3 of 3
A restored subscription points at a slot the publisher never had or has dropped
You seepg_subscription on the restored server lists a subscription whose subslotname matches the name in the error, and the publisher has no such slot
Check
On the logical side, the same message means a subscription that came along with the restore is trying to stream. pg_dump writes subscriptions with connect = false, so no slot is created on the publisher during pg_restore; enabling the subscription later fails until a slot exists. A file-level copy of a subscriber carries its subscriptions too, even when the publisher's slot has been dropped since.
SELECT subname, subslotname, subenabled FROM pg_subscription;Fix
To resume replication, create the logical slot on the publisher, then enable and refresh the subscription (truncate the target tables first if you want a full new copy). If this copy should not replicate at all, detach the slot and drop the subscription, which otherwise fails while the remote slot is missing.
-- resume: on the publisher
SELECT * FROM pg_create_logical_replication_slot('sub1', 'pgoutput');
-- then on the subscriber
ALTER SUBSCRIPTION sub1 ENABLE;
ALTER SUBSCRIPTION sub1 REFRESH PUBLICATION;
-- or remove it from the restored copy
ALTER SUBSCRIPTION sub1 DISABLE;
ALTER SUBSCRIPTION sub1 SET (slot_name = NONE);
DROP SUBSCRIPTION sub1;Verify
Either the publisher's slot shows active = true, or pg_subscription no longer lists the subscription and the error stops.
SELECT subname, subenabled FROM pg_subscription;Confirmed by postgresql.org
How do I stop it coming back?
- Decide before restoring whether the copy is a standby, a point-in-time copy or a fresh subscriber, and remove the settings that belong to the other roles.
- Take standby base backups with -C -S so the slot and the backup are created together.
- After every pg_restore of a database with subscriptions, list pg_subscription and recreate or drop each one on purpose.
- Watch pg_replication_slots on the upstream server, because an abandoned slot keeps reserving WAL until the disk fills.
Sources
- PostgreSQL: pg_basebackup (-R, -S, -C)
- PostgreSQL: Replication settings (primary_slot_name)
- PostgreSQL: Continuous archiving and point-in-time recovery
- PostgreSQL: DROP SUBSCRIPTION
- PostgreSQL: Logical replication subscriptions (manual slot creation)
- PostgreSQL: pg_dump (subscriptions dumped with connect = false)
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.