26

I just installed the desktop version of pg4admin after having difficulty running it using my prior install. I used the following installing documentation to pull this off.

However, when I run the pgadmin4 service, the page gives my the following error:

Unauthorized

The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.

Also, on the terminal I'm getting the following exception:

Starting pgAdmin 4. Please navigate to http://localhost:5050 in your browser.
2016-11-01 01:14:41,981: ERROR pgadmin: The desktop user pgadmin4@pgadmin.org was not found in the configuration database.
2016-11-01 01:14:42,004: ERROR pgadmin: The desktop user pgadmin4@pgadmin.org was not found in the configuration database.
2016-11-01 01:18:45,650: ERROR pgadmin: The desktop user pgadmin4@pgadmin.org was not found in the configuration database.
2016-11-01 01:18:45,664: ERROR pgadmin: The desktop user pgadmin4@pgadmin.org was not found in the configuration database.

Did I miss anything in the install process? What can I do to fix this issue?

Adam Steinberger
  • 545
  • 1
  • 5
  • 16
  • 3
    Did you ever figure out how to fix this? If yes, please accept the answer that helped you. – Jeff G May 14 '18 at 18:31
  • Before you take the security approaches below in an employment or home setting, think about what you're doing. Disabling browser security on a server can cause major issues. Most viruses, malware, spyware, trojans, etc... happen from browsers running in Admin mode (with an Administrator user) on Windows. With the browser security turned off, you'll definitely run into quite a few exploits. Try this instead. https://stackoverflow.com/a/66538220/640205 – JustBeingHelpful Mar 08 '21 at 23:19

13 Answers13

35

In my case the problem is Internet Explorer Enhanced Security Configuration (IE ESC) (btw my OS is Windows Server 2012 R2)

Go to Server Manager, choose Local Server from the left pane. On the right pane, there is "IE Enhanced Security Configuration", the status is "on".
Click on that On, choose Off (I turned off for both the Administrators and Users, I guess one of them should be enough but I was not sure which one).
Click OK, then click the refresh button on top (or close the server manager). Refresh the pg admin4 page (or if that does not work, right click on pg Admin4 system tray icon, then choose "New PgAdmin4 window").

Leonard AB
  • 1,479
  • 1
  • 19
  • 30
  • I additionally needed to kill all postgresql pgAdmin related processes/services (in TaskManager). Then it worked. – jannikb Aug 25 '19 at 20:32
  • 2
    According to @koax26 answer, you can also white list the address instead of turning off the security https://stackoverflow.com/a/57265347/5122657 – Leonard AB Oct 08 '19 at 04:16
11

@Leonard AB
Thanks for the solution. Worked for me. After confirming that was the issue rather than leave IE Enhanced Security Configuration off I white listed http://127.0.0.1.

Within IE:

  1. Click on the Cog and the top right of the browser or go to Internet Options via Control Panel
  2. Click on the Security tab and select Trusted sites in the zone box and then click on the Sites button
  3. Add http://127.0.0.1 to the list and hit close, finally hit ok and confirm it works

Apologies for not adding this as a comment to your post but I don't have a high enough rep.

koax26
  • 163
  • 1
  • 6
  • thanks. I linked this into the comment of my answer. – Leonard AB Oct 08 '19 at 04:17
  • I had the same problem in a Server 2016 after installing pgadmin v4.15. This solution worked for me even in the case of using Chrome for server access – XaviQV Dec 03 '19 at 10:09
10

Delete "pgadmin4.db" file & start pgAdmin4 again.

Linux:

~/.pgadmin/pgadmin4.db

Windows:

%appdata%\pgAdmin\pgadmin4.db

Note: You will lose all of your saved server listing from your previous install.

Murtuza Z
  • 5,639
  • 1
  • 28
  • 52
  • It worked! This happens when you have pgadmin3 previously installed. pgadmin4 can't digest some of the old version configuration. To run both version 3 & 4 in parallel I created "~/.pgadmin4" directory instead and pointed ver 4 to it. – oᴉɹǝɥɔ Nov 01 '17 at 21:18
  • 4
    This didn't work for me. I killed the pgadmin4 runtime, deleted the entire ~/.pgadmin folder and relaunched and still same problem. I'm on Antergos and installed the pgadmin4 package, so I'm not familiar with manual desktop setup. – Peter L May 03 '18 at 21:15
8

in linux ubuntu 16.04 copy the adress in the file ~/.pgAdmin4.14570597673959349582.addr into your browser window. Looks like it contains the key.

8

Following is working for me (using SolydK):

  • right click on "tray icon"
  • select "Configure"
  • set "Browser Command" (e.g. "/usr/bin/firefox" %URL%)
megamin
  • 133
  • 2
  • 5
4

I solved by right clicking on tray icon, settings and changing the URL field to

/usr/bin/firefox "%URL%"

Found it on https://askubuntu.com/questions/1186036/pgadmin4-401-unauthorized-in-ubuntu-18-04

1

Not an answer but a workaround

I solved it installing the pgadmin4-apache2 package and visiting the http://localhost/pgAdmin4 URL

Pipo
  • 4,653
  • 38
  • 47
1

Web-based Pgadmin application uses cookies to store its information.pgAdmin mainly stores 3 cookies namely

  • PGADMIN_KEY
  • PGADMIN_LANGUAGE
  • pga4_session

So, to use the pgAdmin application you must have to enable your browser cookies so that these 3 cookies will stored in your browser.

In Chrome

  • On your computer, open Chrome.
  • At the top right, click More enter image description here and then Settings.
  • At the bottom, click Advanced.
  • Under "Privacy and security," click Site settings.
  • Click Cookies.
  • There click on "Block" toggle button then we will be switched to "Allow sites to save and read cookie data."

Change toggle from block to allow

Then try to open pdadmin4 and you will get your pgAdmin4 home screen.

Diwas Poudel
  • 781
  • 1
  • 11
  • 20
1

With pgAdmin 4 v4.28 and Windows a new behavior has appeared and authentification dialog never open in the browser when you load the program. To fix this change the registry key at HKEY_CLASSES_ROOT\.js\Content Type from text/plain to text/javascript as describe in the FAQ.

GeoGyro
  • 487
  • 12
  • 32
0

In my case, just adding/setting the environment variable SERVER_MODE=True it worked well.

Sergio Lema
  • 1,491
  • 1
  • 14
  • 25
0

For Windows, another option. Tray icon, right click and select "new pgAdmin window..." and in my case used Yandex.browser

0

Comment this line of code out. This is far less invasive than opening up a browser's security. Since you are simply connecting locally, just comment out the tool's security. pgAdmin is typically run from a client computer anyway, not from the machine where the database server resides. So to do a smoke test, this is fine.

Search bar > type "explore.exe" (Windows Explorer) > run as administrator > open this file in a text editor > save file after commenting the line out.

C:/Program Files/PostgreSQL/13/pgAdmin 4/venv/Lib/site-packages\werkzeug\exceptions.py

def __call__(self, code, *args, **kwargs):
    if not args and not kwargs and not isinstance(code, integer_types):
        raise HTTPException(response=code)
    if code not in self.mapping:
        raise LookupError("no exception for %r" % code)
    #raise self.mapping[code](*args, **kwargs) # <-------- comment line 807 in exceptions.py

Right click Windows Task Bar > Task Manager > end process for "pgAdmin 4 Desktop Runtime". This is the pgAdmin server for the pgAdmin 4 Desktop client. This is different from the PostgreSQL server. Then restart pgAdmin in Administrator mode.

JustBeingHelpful
  • 18,332
  • 38
  • 160
  • 245
-5

it's simple , just delete file pgadmin from C:\Program Files (x86)\pgAdmin 4 , and C:\Users\acer\AppData\Roaming\pgAdmin , delete the files , all of it , and install it again