Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

My postgreSQL.conf looks like

# - Connection Settings -

listen_addresses = '*'          # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost', '*' = all
                                        # (change requires restart)
port = 5432                             # (change requires restart)

and I also know that postgres is running

air:data postgres$ ps -aef | grep postgres
  504 16474 16473   0 11:34AM ??         0:00.00 postgres: logger process
  504 16476 16473   0 11:34AM ??         0:00.00 postgres: writer process
  504 16477 16473   0 11:34AM ??         0:00.00 postgres: wal writer process
  504 16478 16473   0 11:34AM ??         0:00.00 postgres: autovacuum launcher process
  504 16479 16473   0 11:34AM ??         0:00.00 postgres: stats collector process
    0 16087 16078   0 10:54AM ttys001    0:00.03 su - postgres
  504 16473     1   0 11:34AM ttys001    0:00.22 /Library/PostgreSQL/9.1/bin/postgres -D/Library/PostgreSQL/9.1/data
  504 16484 16088   0 11:34AM ttys001    0:00.00 grep postgres

But I am not able to connect

 psql -Uuser -W
Password for user user:
psql: 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"?

Also, when I run the following

 lsof -i tcp:5432
 ✘ me@air11:37:13 ⮀ ~ ⮀ netstat -a | grep postgres
tcp6       0      0  *.postgres             *.*                    LISTEN
tcp4       0      0  *.postgresql           *.*                    LISTEN

It says nothing running on port 5432 What am I missing?

UPDATE

My pg_hba.conf looks like

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
share|improve this question
 
Are you on a Mac OS X machine by any chance? (It's generally good to mention your platform) –  Craig Ringer Mar 26 at 23:38
 
My bad, yes, I am using Mac OS X –  daydreamer Mar 27 at 3:37

4 Answers

You need to use the psql program that comes that the PostgreSQL package that you installed instead of the psql in the /usr/bin directory that is part of the Apple system.

For example, if using postgres.app, they say in their documentation:

Mac OS 10.7 ships with an older version of PostgreSQL, which can be started with the following command:

$ psql -h localhost PostgreSQL ships with a constellation of useful binaries, like pg_dump or pg_restore, that you will likely want to use. Go ahead and add the /bin directory that ships with Postgres.app to your PATH (preferably in .profile, .bashrc, .zshrc, or the like to make sure this gets set for every Terminal session):

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
Once your path is correctly set up, you should be able to run psql without a host. (If not, check that the correct version is being loaded in the PATH by doing which psql)

If using another source of pre-packaged postgresql, it's the same thing with different paths.

share|improve this answer

In pg_hba.conf:

host    all             all             127.0.0.1/32            trust

last column change to trust

share|improve this answer
up vote 0 down vote accepted

Not sure why this was happening, but I found postgresapp.com which is pretty good to use

I am using this with http://www.pgadmin.org/ and I am running it smoothly so far

share|improve this answer

you can try to stop service and agian start the service. once you reload the configuration file. check again while it is working or not.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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