Cookbook recipe

Set up streaming replication from scratch

Applies to PostgreSQL 13–17 Last reviewed May 2026 Grounded in source
Estimated investigation4 min

Scenario

You need a hot standby for read scaling and failover. Streaming replication ships WAL to a replica in near real time. Diagnose it On the primary, confirm WAL level and a replication slot: SHOW wal_level; --…

Investigation Path

You need a hot standby for read scaling and failover. Streaming replication ships WAL to a replica in near real time.

Diagnose it

On the primary, confirm WAL level and a replication slot:

SHOW wal_level;   -- replica or logical
SELECT * FROM pg_create_physical_replication_slot('standby1');

Why it happens

A standby replays the primary’s WAL. A replication slot guarantees the primary keeps WAL the standby still needs, preventing the dreaded “requested WAL segment has already been removed”.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • How to fix it
  • Prevent it next time
  • Related & next steps
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Career Impact

This scenario builds production judgment and operational confidence under pressure.

Open Career Dashboard →

Keep going

Related & next steps

Was this helpful?

← All cookbook recipes