This one goes out to the new people who are, as I described myself a few minutes ago, “still building context.”
This error is not this. This error is not that. This is error is that you, perhaps like me, restarted your system recently and didn’t restart Postgres.app.
“I can’t reach the server,” it says. Maybe you, like me, will get stuck on the port thing, thinking that server.py is having some new and terribly exotic error. Server.py is running. What is its problem? It’s RIGHT THERE.
No.
Restart your database server. (Or, y’know, start it.)
Then change your preferences so PostgreSQL starts after login for the duration of your project.
You’re welcome.
This blog post is brought to you by me wishing that I’d found the perfect, straightforward answer to this simple-ass question. Port 5432: not a part of server.py. No, it is Postgres. Just Postgres.
Now you know. Get it.
For Google fu, here’s the relevant text of the screencap above:
OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused Is the server running on host “localhost” (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host “localhost” (fe80::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host “localhost” (127.0.0.1) and accepting TCP/IP connections on port 5432?