'Unable to connect to server: PgAdmin 4
I have installed pgadmin on a new windows laptop and when I try to create a new server, it says:
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 ?
Solution 1:[1]
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
Solution 2:[2]
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.
Solution 3:[3]
You should uninstall Postgres and pgAdmin from your PC. Then install postgres, note that you have the option of installing pgAdmin together with Postgres, so you don't have to download pgAdmin separately. Allow the installation to complete then restart you PC. Hopefully you should be able to create your server/database
Solution 4:[4]
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.
Solution 5:[5]
Instead of directly installing PgAdmin, intall postgresql version. For example - Version 13 of psotgresql. It will ask you to install pgadmin in addition.
Solution 6:[6]
I faced the same problem. So I uninstalled pgAdmin through control panel. after that deleted the folder where pgAdmin was located. Then I went to this link and installed pgadmin whole package from there and now it works fine.
Solution 7:[7]
I was getting this error when I was running pgadmin in a docker container on my machine, which meant that localhost:5432 was not accessible.
I worked around this by using the native version of pgadmin.
Solution 8:[8]
After two years i think this would be of good help to so many people.
You don't have to uninstall postgresql or PGADMIN from your system.
What you need to do i input the username and password for a particular user created on postgresql into the server input box.
And that all you need.
i hope this helps anyone
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jeberdson Abraham |
| Solution 2 | kwoxer |
| Solution 3 | |
| Solution 4 | Bijin Abraham |
| Solution 5 | Disha Goyal |
| Solution 6 | Single-byte |
| Solution 7 | ngood97 |
| Solution 8 | Gabriel soft |

