12
votes

I have installed pgadmin on a new windows laptop and when I try to create a new server, it says:

enter image description here

When I try to run my django app in pycharm it is giving me the same error

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?

How to solve this ?

5
Did you configure your Postgres server to actually run on localhost, port 5432? - Stevy
Do you have a postgres server running locally on your machine? - Matt Seymour
@MattSeymour No, I checked in services.msc but there is no active connection - Rahul Sharma
@Stevy How do I do that ? - Rahul Sharma
If you have installed it correctly, then the default port is 5432. If that is fine, then this error suggest that your server is not running locally. Run your server from sql shell. Then pgAdmin will connect it. - Bidhan Majhi

5 Answers

3
votes

You can configurate your newly created server to run on localhost and port 5432.

First select the “Connection” tab in the “Create-Server” window. Then, configure the connection as follows:

  • Enter your server’s IP address in the “Hostname/ Address” field. Default is localhost.

  • Specify the “Port” as “5432”.

  • Enter the name of the database in the “Database Maintenance” field.

  • Enter your username as postgres and password (use the same password you used when previously configuring the server to accept remote connections) for the database.

  • Click “Save” to apply the configuration.

NOTE You have to either install Postgres on your machine and run it or run it with docker.

6
votes

My teammate also faced this same problem. The mistake was she directly downloaded and installed PG Admin instead of installing PostgreSQL Server first.

After installing PostgreSQL Server, this issue was solved.

You can verify if the folder is created in the below folder, C:\Program Files\PostgreSQL

2
votes

I had the same issue. But in my case I had installed pgadmin in version 9. But also installed version 12 at the same time.

When I now uninstalled version 9, the port was already set in the config of version 12 and not given free.

So my solution was to change the port of version 12 in the postgresql.conf file. Or even simplier, change the port in the server creation from 5432 to 5433. Now you are able to create a server again.

0
votes

I was trying to install PostgreSQL and pgAdmin with an installer that is given here https://www.postgresql.org/download/windows/. This installer includes the PostgreSQL server, pgAdmin; I was facing an error while starting pgAdmin: "The pgAdmin 4 server could not be contacted". I tried different solutions but did not work.

Then I uninstalled both of them, deleted the temp folder C:\Users\%USERNAME%\AppData\Roaming\pgAdmin and delete those ones too %temp%.

Then I installed the pgAdmin separately from this link https://www.pgadmin.org/download/ and it works. If you need to connect it with your local server I think you should install the PostgreSQL server first and then pgAdmin separately.

0
votes

Instead of directly installing PgAdmin, intall postgresql version. For example - Version 13 of psotgresql. It will ask you to install pgadmin in addition.