Common Errors When Setting Up PostgreSQL Streaming Replication
I am a web developer focusing on building web application using Python and Django. Full profile on https://kamal.koditi.my/.
Search for a command to run...
I am a web developer focusing on building web application using Python and Django. Full profile on https://kamal.koditi.my/.
No comments yet. Be the first to comment.
Running a massive, codebase-wide lint or format update using a tool like Ruff is incredibly satisfying for clean code, but it does come with a major side effect: it can completely wreck your git blame
Got this error:- ERRO[0000] running `/usr/bin/newuidmap 738 0 1000 1 1 524288 65536`: newuidmap: write to uid_map failed: Operation not permitted Error: cannot set up namespace using "/usr/bin/newuidmap": should have setuid or have filecaps setuid: e...

So, you tried sending an email from a new VPS for your app’s invitation feature, and… crickets. No email arrived. You thought it’d be as easy as hitting "send," but turns out, sending emails from a server is more like navigating a maze blindfolded. L...

I have a simple script that I run to load my ssh keys into ssh agent. It looks like this:- eval "$(ssh-agent)" ssh-add The problem is, I have to run this in every new terminal I started. And that means typing the key passphrase every single time. Si...

I have been setting up postgresql streaming replication lately so here's some notes on common errors I bumped into during the setup.
standby.signal FileThe Symptom: You complete your base backup, start up the secondary instance, and realize it's accepting write traffic or acting like a completely independent primary database instead of a read-only follower.
The Fix: PostgreSQL needs an explicit flag to boot up in standby mode. If you use pg_basebackup, always include the -R flag. This automatically creates a file named standby.signal in your data directory and writes your standby.auto.conf settings. If you forget it, you can create it manually:
sudo -u postgres touch /var/lib/postgresql/17/main/standby.signal
pg_hba.conf Security WallThe Symptom: Your logs on the secondary server show a frustrating loop of: FATAL: no pg_hba.conf entry for host "10.104.0.5", user "replication_user"
The Fix: PostgreSQL is secure by default and blocks all remote database connections. You must explicitly allow your replica's IP address to connect using the replication keyword. Add this to the bottom of your primary server's /etc/postgresql/17/main/pg_hba.conf:
# Allow replication traffic from the secondary IP
host replication replication_user 10.104.0.5/32 scram-sha-256
Don't forget to reload the configuration on the primary afterward: SELECT pg_reload_conf();.
wal_log_hints Before a FailoverThe Symptom: Your primary crashes, you successfully promote your secondary to master, but when the old primary comes back online, pg_rewind fails with: pg_rewind: error: target server needs to use either data checksums or "wal_log_hints = on"
The Fix: pg_rewind is a lifesaver that prevents you from having to completely re-download massive databases after a failover, but it requires extra data in the logs to do its job. You must enable wal_log_hints = on in your postgresql.conf on both servers before any disaster happens. If you didn't, your only option is to delete the old primary's data and run a slow, fresh pg_basebackup.
wal_keep_sizeThe Symptom: Replication works beautifully for a few hours, but suddenly breaks under heavy write loads with an error indicating that the secondary has "fallen behind" or that WAL segments have been cleared.
The Fix: The primary server automatically purges older Write-Ahead Log (WAL) segments to save disk space. If your secondary experiences a brief network hiccup or a massive write-heavy benchmark (like pgbench), the primary might delete the logs before the secondary can read them. Give your replica a safety buffer by increasing this value on your primary:
# In postgresql.conf (PostgreSQL 13+)
wal_keep_size = 1024MB # Adjust higher based on your transaction volume
Before you pull your hair out debugging, remember that PostgreSQL's error logs are incredibly descriptive. On Debian systems, bypass the systemd journal and check the direct cluster log file:
sudo tail -n 50 /var/log/postgresql/postgresql-17-main.log
Nine times out of ten, your fix is just a quick IP tweak in pg_hba.conf or a forgotten parameter in postgresql.conf away!