+3 votes
in Databases by (56.5k points)

I installed PostgreSQL 9.5 on Windows10, but when I try to access PostgreSQL server using PSQL, I am getting the following error...

Server doesn't listen
The server doesn't accept connections: the connection library reports 
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? 

It seems that the PostgreSQL server is not running on my machine. How can I start/run PostgreSQL server on Windows machine?

1 Answer

+1 vote
by (71.8k points)
selected by
 
Best answer

There might be some good ways to start PostgreSQL on Windows, but I remember the following dirty way to do that.

You need to run the executable 'pg_ctl' that should be present in the bin folder of PostgreSQL installation. Use CD command to go to the bin folder of the installation and then type the command highlighted below.

C:\Program Files\PostgreSQL\9.5\bin>pg_ctl start -D "C:\Program Files\PostgreSQL\9.5\data"
 

The server will start running and you will see the following message on the terminal.

server starting

C:\Program Files\PostgreSQL\9.5\bin>2016-10-21 17:26:10 MDT LOG:  redirecting log output to logging collector process
2016-10-21 17:26:10 MDT HINT:  Future log output will appear in directory "pg_log".


...