7
votes

First of all : I'm a novice in what touches to databases.

I'm using postgreSQL with pgAdmin III, and it worked perfectly fine until some days ago : Some days ago, when I was not working on it, I saw in the "background process" of Windows that several identical postgreSQL programs (?) were running, and I decided to stop them, because I was not using them at the time. Mistake : Now, when I try to connect to the server (on localhost), I receive the error message :

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

I already took a look on similar topics on stackoverflow, looked the listen_address file, the postgresql.conf and pg_hba.conf files, but everything seems to be "normal" (according to what I read in these topics).

I posted this because... well, I didn't find any other person that did what I did (stopping the background process, and then not being able to reconnect).

6
You did restart the Postgres service, did you? (btw: it's normal to have more than one postgres process even when the DB is idle, see e.g.: here: postgresql.org/docs/current/static/monitoring-ps.html). - a_horse_with_no_name
Well... Since I didn't remember what I did when I connected to the server the first time, after searching a bit how to restart it (in vain), I supposed that pgAdmin automatically launched it when I try to connect... Apparently that's not the case ? - Oscar Pasta
No, pgAdmin does not start any server, it only connects to them. In a default installation, Postgres is registered as a Windows service. So you need to start the service from the Windows control panel. - a_horse_with_no_name
I tried to start the postgres service (in commande line, since I couldn't find it in the control panel - no error occured, so apparently, it worked), but I can't see it in the background (or foreground) process, and I still can't connect. - Oscar Pasta

6 Answers

16
votes

Use Services (Start → Run → services.msc) and look for the postgresql-[version] service. Is it running?

  • If not, try to start it.
    • If that works, you can make it startup automatically by changing the Startup Type with Windows to Automatic; or perhaps Automatic, delayed start if you don't want it to slow down startup too much.
  • If you can't start it, you may have just installed pgAdmin and not installed PostgreSQL itself.
  • If it won't start open the Event Viewer (Start → Run → Eventvwr) and look for error messages relating to the PostgreSQL service.
3
votes

Edit \data\postgresql.conf find and edit this line listen_addresses to

listen_addresses = '*'

and uncomment

port = 5432
1
votes

For security reasons, PostgreSQL does not listen on all available IP addresses on the server machine initially. In order to access the server over the network, you need to enable listening on the address first.

For PostgreSQL servers starting with version 8.0, this is controlled using the "listen_addresses" parameter in the postgresql.conf file. Here, you can enter a list of IP addresses the server should listen on, or simply use ''* to listen on all available IP addresses. For earlier servers (Version 7.3 or 7.4), you'll need to set the "tcpip_socket" parameter to 'true'.

You can use the postgresql.conf editor that is built into pgAdmin III to edit the postgresql.conf configuration file. After changing this file, you need to restart the server process to make the setting effective.

If you double-checked your configuration but still get this error message, it's still unlikely that you encounter a fatal PostgreSQL misbehaviour. You probably have some low level network connectivity problems (e.g. firewall configuration). Please check this thoroughly before reporting a bug to the PostgreSQL community.

Credits: PostgreSQL - Guru Hint.

1
votes

If on Windows, it could be a Firewall issue. Try adding rules (TCP as protocol should work) for postgres using post 5432 (or whatever post you might use).

0
votes

Just go to task manager -> services -> postgresql-x64-9.4 - PostgreSQL Server 9.4(right click) -> start service From there just refresh postgresql and connect, and everything will be fine.

0
votes

I tried all the given methods. The postgresql service was running fine. Finally, logged in as administrator in Windows. It worked. Guess, postgresql doesn't allow itself to be run in a non-admin user.