macospostgresql

How to check status of PostgreSQL server Mac OS X


How can I tell if my Postgresql server is running or not?

I'm getting this message:

[~/dev/working/sw] sudo bundle exec rake db:migrate 
rake aborted!
could not connect to server: Connection refused
    Is the server running on host "localhost" and accepting
    TCP/IP connections on port 5432?

Update:

> which postgres
/usr/local/bin/postgres
> pg_ctl -D /usr/local/bin/postgres -l /usr/local/bin/postgres/server.log start
pg_ctl: could not open PID file "/usr/local/bin/postgres/postmaster.pid": Not a directory

Update 2:

>pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
server starting
sh: /usr/local/var/postgres/server.log: No such file or directory

Solution

  • The simplest way to to check running processes:

    ps auxwww | grep postgres
    

    And look for a command that looks something like this (your version may not be 8.3):

    /Library/PostgreSQL/8.3/bin/postgres -D /Library/PostgreSQL/8.3/data
    

    To start the server, execute something like this:

    /Library/PostgreSQL/8.3/bin/pg_ctl start -D /Library/PostgreSQL/8.3/data -l postgres.log