Report this

What is the reason for this report?

Postgresql: terminating connection due to administrator command

Posted on July 3, 2025

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!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.