1

Postgres Installation : I've used macports and followed the below command to install postgres. Here's the link https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#macports

    $ sudo port install postgresql83-server

Unable to create database : When I try to create a database from the terminal application by using the below command

    $ createdb mydb

I get this error message

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

Could you please help !!

wildplasser
  • 43,142
  • 8
  • 66
  • 109
SpaceX
  • 2,814
  • 2
  • 42
  • 68

2 Answers2

1

This is a well known issue on Mac OS X.

Apple bundle their own version of PostgreSQL with some OS X versions. This has a different default socket location. If Apple's psql and libpq are first on your PATH and DYLD_LIBRARY_PATH then you'll be using old versions of the tools that default to Apple's locations for the socket.

You should fix your PATH so that the MacPorts bin dir is first, so the correct psql and pg_config are found first. Alternately you can probably just:

psql -h /tmp

or:

psql -h localhost

... but since using psql from a mismatched version can result in odd results, it'd much better to fix your PATH.

There's a lot more information on Stack Overflow about this, and a Google search for "OS X" "postgresql" "could not connect to server: No such file or directory" is rather informative.

Also: Please don't install PostgreSQL 8.3. it's outdated and unsupported. Install PostgreSQL 9.2, the current version. Why would you possibly use 8.3?

Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
  • Hello Craig, Thanks for your advice, I've upgraded to version 9.2 with not much success. I am a novice in programming, could you please advice how I could fix the PATH ? – SpaceX Jun 29 '13 at 16:04
0

Its telling you that the database isn't started. When you installed Postgres, macports told you to run a couple commands to initialize and start Postgres, and another (launchctl ...) to start Postgres when your computer starts. Did you run those?

If not see this post (change the file locations as needed):

https://shifteleven.com/articles/2008/03/21/installing-postgresql-on-leopard-using-macports/

Denis de Bernardy
  • 75,850
  • 13
  • 131
  • 154