MacOS – PostgreSQL- Cannot connect to server

macospostgresqlterminal

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?

Best Answer

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