PostgreSQL errors say plainly what went wrong, so read the message. "Connection refused": Postgres isn't running or isn't listening at that address. Authentication failures, including ones that mention pg_hba.conf: the login or the access rules are wrong. Too many connections (error code 53300): you've used every connection. Statement timeout: a query ran longer than statement_timeout allows. A missing relation (table): usually a migration that didn't run.
What's the problem
Your app fails with a Postgres error in the logs or on screen, often starting with FATAL: or ERROR:.
Why it happens
- Connection refused: the server is stopped, listening on a different address or port, or blocked by a firewall.
- Authentication failed: wrong password, or the server's access rules (
pg_hba.conf, or a cloud provider's settings) don't allow your app's address or require SSL. - Too many clients: connections are leaking or there's no pooling.
- Statement timeout: a slow query or a lock.
- Relation does not exist: migrations didn't run on this database, or the app is pointed at the wrong one.
- Disk full or out of memory on the database server.
How to fix it
- Copy the exact error message from your app's logs.
- For "connection refused", check the database is running and the host and port in your app's settings are right.
- For authentication errors, check the password and the access rules in
pg_hba.conf(or your cloud provider's settings); many cloud databases require SSL connections. - For too many connections, see too many connections.
- For timeouts, see database timeout.
- For missing relations, run your migrations against the live database and check the connection string points to the right one.
What Preventionlabs checks
One click runs the full report on your domain. For this problem it shows whether your site loads, how fast, and where its redirects go; uptime checked every 5 minutes, with an email when the site goes down and when it is back. With Cloudflare connected, it also shows which pages returned server errors (5xx) to visitors, and when; recent deploys and account changes, with their times. It can't connect to your database, so the database error itself is in your host's or database provider's logs.
Run your free reportYour first report is free, no card needed. Then A$50 a month, up to 10 domains. Read-only: it never changes anything.
Sources
- PostgreSQL: Connections and Authenticationofficial docs
Whenever the number of active concurrent connections is at least max_connections minus superuser_reserved_connections , new connections will be accepted only for superusers.
- PostgreSQL: Client Connection Defaultsofficial docs
Abort any statement that takes more than the specified amount of time.
- PostgreSQL: The pg_hba.conf Fileofficial docs
Client authentication is controlled by a configuration file, which traditionally is named pg_hba.conf and is stored in the database cluster's data directory.
- PostgreSQL: PostgreSQL Error Codesofficial docs
53300 too_many_connections