Postgres not able to start

Posted August 25, 2016 15.7k views

I have a problem with postgres not being able to start:

  • Starting PostgreSQL 9.5 database server * The PostgreSQL server failed to start. Please check the log output: 2016-08-25 04:20:53 EDT [1763-1] FATAL: could not map anonymous shared memory: Cannot allocate memory 2016-08-25 04:20:53 EDT [1763-2] HINT: This error usually means that PostgreSQL’s request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 1124007936 bytes), reduce PostgreSQL’s shared memory usage, perhaps by reducing sharedbuffers or maxconnections. This is the response that I got. I checked the log in tail -f /var/log/postgresql/postgresql-9.5-main.logand I can see the same response.

Can someone suggest what can be the problem?

I used following commands to stop/start the postgres server on Ubuntu 14.04 with postgres 9.5:

sudo service postgresql stop
sudo service postgresql start

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.

Submit an Answer
1 answer

As the error message indicates, you appear to not have enough available memory to start the service. You can check your available memory at any time by running the command:

free -m

When you see this error, aside from the suggestions for optimizations presented by the error message you can also add a swap file and/or upgrade to a larger droplet in order to have more memory+swap available for the PostgreSQL process.

by Justin Ellingwood
One of the easiest way of increasing the responsiveness of your server and guarding against out of memory errors in your applications is to add some swap space. In this guide, we will cover how to add a swap file to an Ubuntu 16.04 server. <$>[warning] [label...