Hi guys, I’m trying to create materialized view for my table with ~5 million records. For some reason however I get the following error: “terminating connection due to administrator command”.
AI pointed me in the direction of a possible failover or maintenance scenario which wasn’t recorded in the DO Dashboard log-overview.
I already tried multiple times today, but the query fails and I’m not able to debug the cause.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hi guys, after some debugging I ran the following sql-query: SELECT pid, application_name, state, replay_lag, write_lag FROM pg_stat_replication;
This showed me my database replication was like 5 days behind. For this reason I created a ticket with DO-support, where the cloud engineer told me this was triggered due to hitting a 85% capacity threshold. The engineer adviced me to clear some data or upsize the database, which in turn allowed me to create a materialized view.
In summary: my database was close to getting full (> 85% capacity) and therefor WAL pressure on pghoard exceeded the threshold and therefor got killed.
Hope this helps anyone in the future :)
Kind regards, Robbert
This usually happens when the PostgreSQL server forcefully terminates a connection—often due to a manual action like restarting the server, killing a backend process, or timeout policies being enforced. It’s common during maintenance windows, deployment cycles, or when idle connections exceed limits.
If you’re seeing this unexpectedly, it might be worth checking:
If pg_terminate_backend()
was called manually or by a script
If there’s an automatic connection pool manager (like PgBouncer) resetting things
Server resource constraints or configuration changes triggering auto-kills
We faced a similar issue during one of our Odoo deployments, and Webkul helped troubleshoot it. They identified that a long-running query was holding up the connection and getting terminated during a scheduled restart. They adjusted the timeout settings and added graceful handling in the application layer.
If this happens during production hours, reviewing logs (postgresql.conf
, system logs) and checking cron jobs or external services interacting with the DB would be a good start.
Anyone else faced this in a high-traffic app? Would love to hear your mitigation strategies.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.