Can not connect to pgAdmin server

I installed PostgreSQL on Windows 10 and the server appears to be in Task Manager. However, I get this error when opening pgAdmin4:

Failed to connect to the pgAdmin application server. Click here to try again.

Any ideas for what the problem is?


Solution 1:

Did you try running the pgAdmin application as an administrator ? I was having the same issue, but ran the application as an administrator and was able to connect.

Solution 2:

I installed pgAdmin 4 via the EnterpriseDB PostgreSQL installer as well as the stand-alone Windows installer and had the same problem both times. Then I came across this: https://www.pgadmin.org/docs4/dev/desktop_deployment.html

It seems the Windows installer configures pgAdmin for server mode, and we need to switch it to Desktop mode. Why the installer does not have an option for this I do not know.

You should be able to getting it working by doing the following:

  • Modify config_local.py file in web folder, adding SERVER_MODE = False
  • Install python for windows, checking the box to add it to your path
  • Install the python packages necessary to run setup.py (see below)
  • Delete C:\Users\%USERNAME%\AppData\Roaming\pgAdmin\pgadmin4.db since upgrade mode seems to not work.
  • Run python setup.py from any command prompt

Here are the python packages I think I installed to get setup.py to work

pip install flask
pip install flask_security
pip install flask_babel
pip install django-htmlmin
pip install python-dateutil
pip install flask_sqlalchemy

Solution 3:

I had the same problem with pgAdmin 4 1.6 on Windows 7. The solution was simply to delete %appdata%\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.