58

I downloaded PostgreSQL from their site - http://www.postgresql.org/download/windows

However, I can't create a database from pgAdmin and get a message:

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

Do I have to create a windows service? How is it called? Do I have to install it separately?

EDITED

Let me explain myself. I am trying to run the service. I tried running postgres.exe from the command line but still it does not run.

What could run the database?

EDITED

The problem was with my installation file. I downloaded it again - and it worked well!

Jon Tirjan
  • 3,556
  • 2
  • 16
  • 24
Dejell
  • 13,947
  • 40
  • 146
  • 229

17 Answers17

139

Use services (start -> run -> services.msc) and look for the postgresql-[version] service.

  • If it is not there you might have just installed pgAdmin and not installed PostgreSQL itself.
  • 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.
  • If it does start check the startup type, if you want it to start with windows it should be "Automatic"; or perhaps "Automatic, delayed start" if you don't want it to slow down startup too much.

Adding to the first, because in a different comment you've said the service isn't there. It is possible to download a standalone pgAdmin so you can connect to an external PostgreSQL database. It would seem you have done such a thing, or explicitly chosen to not add the service. Just try the One Click Installer, which still allows proper configuration of installation directory despite its name.

ontrack
  • 2,963
  • 2
  • 15
  • 14
  • 3
    I actually downloaded the OneClickInstaller. I don't know why I don't have the service in the list! – Dejell Dec 19 '10 at 11:58
  • 3
    When I start my postgresql9.1, it automaticall stoped by giving message some service stopautomatically. – ANIL Jun 14 '13 at 09:00
  • even when the service says it's stopped, the problem with refused connection is resolved (for me). trying to start the service again shows: postmaster.pid already exists. implying that postgres is now running – bibangamba Oct 11 '16 at 08:27
  • nice answer! for some reason this service has a tendency to crash and fail to start. if and when it does it isn't configured by default (although default is automatic start) to restart itself. I think Postgres really shit the bed on this one. I dunno why their DB is so unstable. – tatsu Jan 17 '18 at 08:42
  • @ANIL right click on the Postgresql sevice and select properties > go to log on tab > select first option and tick the check box> then start the service . – bit-shashank Apr 20 '18 at 08:06
  • Worked great for me. Especially if you play with postgresql.conf you might setup something in the way server won't start. With 'start -> run -> eventvwr' I have found the error message explaining what I did wrong. – Miro Apr 25 '19 at 23:09
  • Worked fine for me. – Abdul Wahab Nov 29 '19 at 13:10
  • @ontrack thanks man. I just started the server and boom...!!! It starts working. Saved my time. – Kush Singla Mar 14 '21 at 14:53
3

I have the solution to this problem enters (Start -> Run -> services.msc) are looking for the postgresql service once you localizas le das Properties---> login and you disable the account you have and what you leave as the local system account , save and restart the programs pgadmin3 and ready should operate.

Greeting from Colombia

Jhon
  • 41
  • 2
2

You might get a more descriptive error message if you tried to start the service from command line using this command:

"C:\Program Files\PostgreSQL\9.5\bin\pg_ctl.exe" start -N "postgresql-x64-9.5" 
  -D "C:\Program Files\PostgreSQL\9.5\data" -w

The log file would be at C:\Program Files\PostgreSQL\9.5\data\pg_log. Note that paths and service name might be different depending on your installation.

Ahmad Abdelghany
  • 11,983
  • 5
  • 41
  • 36
2

(start -> run -> services.msc) and look for the postgresql-[version] service then right click and enable it

Anaurg
  • 21
  • 1
2

You only need to do

pg_ctl register

then execute servcies.msc

enable the "PostgresSQL" and set to auto

then, your postgresql will run like the "server".

Frank Liao
  • 855
  • 1
  • 8
  • 25
2

Your server running on port 5432 but in the properties, the port is set to 5433.

You must go to pgAdmin, click on database version, ex: PostgresSQL 10 and edit properties.

A new window appears and you need to change the port to 5432 [this is default port].

1

The solution was simply to comment the lines "work_mem=256MB" and "maintenance_work_mem=$3GB" in the file postgresql.conf and try to start the postgresql service. (start -> run -> services.msc) and look for the postgresql-[version] service then right click and start.

Ruslan
  • 101
  • 1
  • 5
1

Checking the port may work.

On pgAdmin page at the top, go to Properties and check the port if it is same with the one provided during the setup. If not click the edit button on the top right and change the port.

1

check if you really installed postgresSql from here not only the pgAdmin4

Meriem Bader
  • 112
  • 2
  • 15
0
  1. check conenctionstring
  2. check SSL
  3. check firewall
  4. if u use VS studio, check for db driver
Bonshington
  • 3,970
  • 2
  • 25
  • 20
0

I'm not on windows, but I think you can use the pgAdmin you just installed to configure a server connection and start the server.

Tobu
  • 24,771
  • 4
  • 91
  • 98
  • I think it's just a matter of [finding the right menu](http://xkcd.com/627/) to start the service. – Tobu Dec 19 '10 at 10:11
0

Your server might not be running. This can have 2 issus IMO:

  1. I had the problem that the permissions were not set on the postgres folders and so the service was not able to start. I have no idea why that happend but giving proper permissions on the root postges folder and subfolders did the trick. If I recall it correctly, postgres is also installed as a service so you should find it in the Service List

  2. To start the server, you have a startcommand in your Startmenu. Somewhere at Start -> PostgreSQL -> Start Service/Server/... (haven't used it on Windows for a long time but it should be there).

DrColossos
  • 12,656
  • 3
  • 46
  • 67
  • 1
    I tried Start -> PostgreSQL -> Start Service/Server/ but there is not start service/server there – Dejell Dec 19 '10 at 11:21
0

Please Download from this

https://www.enterprisedb.com/downloads/postgres-postgresql-downloads

install above downloaded file

then

The solution was simply to delete %appdata%\pgAdmin (win key + r then type %appdata% got folder pgAdmin) which was created by an earlier version. On systems other than Windows, there probably is a pgAdmin directory in your user directory. Of course, all session settings etc. are gone after deleting this.

YasirPoongadan
  • 683
  • 6
  • 19
0

you to restart services PostgreSQL from task manager click ctrl+alt+delete then chose services the postgresql-[version] chose the option to run automatically then start and apply ->ok

Mohammed Al-Reai
  • 2,344
  • 14
  • 18
0

Use Services

  1. Windows -> Services
  2. check your PostgresSQL is started or in running state. ( If it's not then start your services for PostgresSQL).
  3. Close services and check again with your PostgresSQL.

This will start PostgresSQL servers as normal.

Ankit Garg
  • 39
  • 1
0

On windows, Just go to the 'Services'. Start/Restart the postgresql-X64 service (click on this service, a dialog box will appear, click Start then OK).Refresh the browser window where postgre db is appearing. It worked for me as my service was in stopped state somehow.

0

In my case, it was the Log On issue. This is how I solve the issue:

  1. Click the Windows button then search Services, open Services
  2. Search postgre-xxx service like this enter image description here
  3. If the status is empty, try right click then choose start
  4. If you get an error like 'could not start postgre...', try right click and choose properties
  5. choose Log On tab
  6. choose Local System Account

enter image description here

  1. click OK, then right-click the service and try to start the service
Yodi S.
  • 106
  • 1
  • 5