PostgreSQL Connection Refused

dino9239 picture dino9239 · Mar 14, 2017 · Viewed 30.8k times · Source

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!

Answer

 tayfun Kılıç picture tayfun Kılıç · Oct 31, 2018

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.