I have a website in production with low traffic (10-20 rpm). The application servers runs on the same box as the database, connection to the DB is done via localhost

For a few months everything has been running fine.

About 5 days ago Postgres started to randomly returns this error, about 1 error every 100 reqs :

server closed the connection unexpectedly
This probably means the server terminated abnormally before or while processing the request.

No major modification was done to the app, database or system setup.

If i understand the error message correctly, it means the database process was killed ?

I'm trying to understand what can cause this error :

  • Postgres logs don't show anything (no log around error time)
  • Kernel logs don't show anything either (no log around error time)
  • Syslog only shows that a cron jobs started the requests that failed with this error

Memory usage on the server seems ok (70%), i have plenty of free disk space.

When i manually connect to Postgres through psql or the ruby PG client i can execute select and update queries.

I already had a look at this question : PostgreSQL Error : server closed the connection unexpectedly

I tried to re-index the tables. I also performed a pgdump which worked fine (i didn't restore data)

Environment :

  • Ubuntu 14.04
  • Postgres 9.4
  • Database size is about 6.5GB

App connecting to the DB :

  • Ruby on Rails 4.2
  • PG gem 0.18.2
  • If auditd is active (otherwise activate it), does ausearch -m ANOM_ABEND -ui postgres report the abnormal terminations ? If yes, arrange to get core dumps – Daniel Vérité Jul 24 '15 at 17:30
  • As recommended on the link you provide, doing a restore might really be a good thing. If possible, provide the settings you modified in your postgresql.conf and maybe /etc/sysctl,conf (if any). – KookieMonster Jul 25 '15 at 7:34
  • 1
    @vdaudry - I know its been 2 years, but did you figure out the issue? – mountainclimber11 Sep 8 '17 at 19:25

Browse other questions tagged or ask your own question.