Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL Connection Refused

I have installed PostgreSQL. However everytime I try to connect through PGAdmin or through psql it gives me the below error.

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? 
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?

I checked the postgresql.conf file and the line: listen_addresses = '*' isn't commented out.

Also this is how my pg_hba.conf file is set:

# IPv4 local connections:
  host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
  host    all             all             ::1/128                 trust

Can anyone please advise on how I can resolve this issue?

Thanks!

like image 485
dino9239 Avatar asked Mar 14 '17 20:03

dino9239


People also ask

Why is postgres connection refused?

“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.

How do I open port 5432?

Open Windows Firewall Port As an alternative you can go to Control Panel -> Systems and Security -> Windows Firewall -> Allow a program or feature through Windows Firewall -> Advanced Settings -> New Rule: Rule Type: Port. TCP or UDP: TCP. Specific local ports: 5432.

Can't connect to server connection refused pgAdmin?

If pgAdmin displays this message, there are two possible reasons for this: the database server isn't running - simply start it. the server isn't configured to accept TCP/IP requests on the address shown.


1 Answers

Use services "start -> run -> services.msc" and look for the postgresql-[vers] service.

If it is not running try to start it, if it won't start open the event-viewer (start -> run -> eventvwr) and look for error messages relating to the PostgreSQL service.

like image 197
tayfun Kılıç Avatar answered Oct 13 '22 23:10

tayfun Kılıç