Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? [closed]

Tags:

postgresql

I'm working on Django. I use PostgreSQL database.

Full error says:

could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? 

Do you have any idea?

like image 604
user2582546 Avatar asked Jul 15 '13 07:07

user2582546


People also ask

Could not connect to server Connection refused Is the server running on host localhost PostgreSQL?

“Could not connect to server: Connection refused” To be sure that PostgreSQL is running, you can also restart it with systemctl restart postgresql. If this does not fix the problem, the most likely cause of this error is that PostgreSQL is not configured to allow TCP/IP connections.

Can't connect to Postgres server Windows?

First, double check that the Postgres process is running where you expect it to be. If you are trying to connect to a Postgres instance on the same host as your terminal, you can run lsof -p :5432 which will show which, if any, processes are listening on that port. The postgres process should be connected there.

Could not connect to server could not connect to server connection refused 0x0000274D 10061?

could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0. 0.1) and accepting TCP/IP connections on port 5432? Is Postgres starting on your PC (which O.S and Postgres version are you using?)? Check that windows firewall isn't blocking the ports.


1 Answers

Wild stab in the dark: You're on a machine with an IPv6 resolver where localhost defaults to the IPv6 address ::1, but listen_addresses in postgresql.conf is set to 127.0.0.1 or 0.0.0.0 not * or you're using an older PostgreSQL built with a C library that doesn't have transparent IPv6 support.

Change listen_addresses to localhost and make sure localhost resolves to both the IPv4 and IPv6 addresses, or set it to ::1, 127.0.0.1 to explicitly specify both IPv4 and IPv6. Or just set it to * to listen on all interfaces. Alternately, if you don't care about IPv6, connect to 127.0.0.1 instead of localhost.

See this Google search or this Stack Overflow search for more information.

(Posting despite my close-vote because I voted the question for migration).

like image 107
Craig Ringer Avatar answered Oct 10 '22 10:10

Craig Ringer