I am working to run PostgreSQL is running locally but I cannot connect. I installed postgress using brew, then I downloaded http://postgresapp.com

When I try to create a database

createdb: could not connect to database postgres: could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

I tried to troubleshot this by using :

sudo sysctl -w kern.sysv.shmall=65536
sudo sysctl -w kern.sysv.shmmax=16777216

But nothing work out.

Any ideas how to solve this

  • Don't know about mac but postgres is not running. You have to start the postgres service before doing anything Jan 17, 2014 at 14:10

2 Answers 2


If you have installed postgresql with brew there's one createdb that comes with it and that will connect to brew's postgresql.

Then if you have also installed Postgres.app there's another createdb at a different location that will connect to Postgres.app's postgresql.

Since OS X also ships with its own createdb in /usr/bin, that's a third createdb that expects to connect to Apple's postgresql, which is not running unless it's OS X Server Edition. According to the error message, this is the one that you're trying to use and which fails.

The solution is to use the createdb command that comes with the PostgreSQL you're actually running. Locate its directory and type the full path of createdb, as in /Applications/Postgres.app/Contents/MacOS/bin/createdb, and/or change your $PATH as suggested in postgresapp's doc.

This is a common problem for PostgreSQL on Mac OS X due the existence of many concurrent packages and of client-side programs pre-installed by Apple.

  • Do you mean by changing the path in .profile, adding this line PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" Jan 17, 2014 at 22:35


create the directory where you want the database files to be:

mkdir /postgres_data

chown postgres /postgres_data

then initialize the directory:

initdb /postgres_data --encoding=UTF8

start the database engine:

pg_ctl -D /postgres_data start

Now you can create your database:

createdb test
  • I got this error message when I try to initdb : Data page checksums are disabled. fixing permissions on existing directory /postgres_data ... initdb: could not change permissions of directory "/postgres_data": Operation not permitted Jan 17, 2014 at 22:31
  • Try executing the command as the postgres user su postgres Jan 18, 2014 at 11:19
  • It says that "-bash: initdb: command not found" Jan 19, 2014 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.