How to fix postgres startup error in OS X


I have to write this post as I have encountered the situation fews times in the recent past. So goes to some of my colleagues as well. The reason could be anything from improper shutdown, PIDs (process ids) issue, incompatible database files (after an upgrade) etc.

PostgreSQL startup error

I have listed down step by step instructions solve some of these problems assuming that you have installed PostgreSQL using homebrew. If not you have to substitute the path with your custom installation path.

Step 1: The first step to solve any problem is looking at the logs first.

tail -f /usr/local/var/postgres/server.log

or the path to the log file if you have installed it in a different path.

PostgreSQL server logs

Step 2:

The error could be anything but I have listed down some common problems and solution.

Problem 1:

FATAL: lock file “” already exists

HINT: Is another postmaster (PID 34263) running in data directory “/usr/local/var/postgres”


You can choose to kill the process using the command,

kill -9 


rm /usr/local/var/postgres/

PostgreSQL PID already exists

Problem 2:

FATAL: database files are incompatible with server

HINT: The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.5.3


The problem could be because of your recent postgresql server.

  • If you are not worried about your existing data then you can do the following,
    rm -rf /usr/local/var/postgres && initdb /usr/local/var/postgres -E utf8
  • To migrate existing data from a pervious major version, please read this upgrading guide from PostgreSQL which will help you to back your data using
    pg_dumpall > data_dump

    which is quite useful.

Step 3:

Now its time to sart the server,

Run the following command from your terminal to start the server manually,

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log.start

and make sure its running by running

ps aux | grep postgres

Grep Postgres Status


pg_ctl -D /usr/local/var/postgres status

Check PostgreSQL Status

Leave a Comment

Your email address will not be published. Required fields are marked *