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 !!

2
  • 2
    stackoverflow.com/a/8482546/905902 (OSX thingy) BTW: pg8.3 is very old. You should start by installing a later version such as 9.2 or 9.1 Commented Jun 29, 2013 at 11:09
  • You should also consider using homebrew instead Commented Oct 20, 2013 at 17:01

2 Answers 2

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?

Sign up to request clarification or add additional context in comments.

1 Comment

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 ?
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/

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.