2

PREFACE: I just bought my first Mac laptop a week ago so that I could get some work done on my trip, but so far I've spent most of my time trying to solve an issue with PostgreSQL. Something went wrong and I don't know what caused it.

SPECS:

Macbook Air OS X Yosemite (10.10.5)

psql (PostgreSQL) 9.4.4 installed with Homebrew

ISSUE: I receive this error when attempting to connect to my database:

2015-09-28 16:18:18 ERROR  : ERROR:  could not open extension control file "/Library/PostgreSQL/9.4/share/postgresql/extension/postgis.control": No such file or directory
2015-09-28 16:44:23 ERROR  : Error connecting to the server: could not connect to server: Connection refused
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

I've tried a bunch of different things to fix it, but Ive gotten nowhere. As far as I can tell, /tmp/.s.PGSQL.5432 does not exist on my system, but I may not have found the correct search syntax. I've been using find ~ -name ".s.PGSQL.5432". How should I go about troubleshooting this?

EDIT: Following up on a comment:

Attempting to run pg_ctl -D /usr/local/var/postgres start results in the following experience:

$ pg_ctl -D /usr/local/var/postgres start
pg_ctl: could not open PID file "/usr/local/var/postgres/postmaster.pid": Permission denied
$ sudo pg_ctl -D /usr/local/var/postgres start
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
$ su PostgreSQL
Password:
bash-3.2$ pg_ctl -D /usr/local/var/postgres start
pg_ctl: could not open PID file "/usr/local/var/postgres/postmaster.pid": Permission denied
bash-3.2$ sudo pg_ctl -D /usr/local/var/postgres start

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

Password:
postgres is not in the sudoers file.  This incident will be reported.
bash-3.2$ 

It seems that it is asking me to run a sudo command from an unprivileged user account. I don't quite know what to do with that. Should this be placed in a seperate question?

  • I think the last paragraph is this question and you need to edit it to make it clearer - posters usually runs under user postgres so you will need an admin account or use Postgres.app – Mark Oct 8 '15 at 11:18
1

This means that you don't have an instance of PostgreSQL running right now.

Try to rerun your instance of PostgreSQL:

pg_ctl -D /usr/local/var/postgres start
  • $ pg_ctl -D /usr/local/var/postgres . pg_ctl: no operation specified Try "pg_ctl --help" for more information. – Adam Starrh Oct 8 '15 at 11:08
  • @AdamStarrh sorry, please look at the updated answer – Daniil Ryzhkov Oct 8 '15 at 11:09
  • I've tried that, added it to the question – Adam Starrh Oct 8 '15 at 11:13
  • @AdamStarrh Press CTRL+D to log out from postgres user and try to run sudo pg_ctl -D /usr/local/var/postgres start (you should be logged in as user with administrator privileges) – Daniil Ryzhkov Oct 8 '15 at 11:15
  • 1
    I ran initdb -D /usr/local/var/postgres and it seemed to spin it back up!! I can run it now with postgres -D /usr/local/var/postgres/ Now I just have to figure out how to get my user roles back, but this helped me tremendously! – Adam Starrh Oct 8 '15 at 11:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .