How to Fix the pgAdmin 4 v3.0+ Port Number

I just installed PostgreSQL 10.4, and noticed that the pgAdmin 4 v3.0 interface packaged with that version uses a local web server and browser interface. By default, the application appears to use an ephemeral port (49152 to 65535) assigned by the OS (Windows 10 in my case). However, I'm working in an environment where the firewall is setup to block HTTP connections, which prevents connecting to the pgAdmin website. Is there a way to fix the port number, instead of using an OS-assigned ephemeral port?

I have looked through the pgAdmin 4 v3.0 documentation, but couldn't find anything about this type of configuration. As a work-around, I know that I can install pgAdmin 4 v2.1 using the stand-alone installer, but I hate the idea that we will never be able to upgrade if we use that approach.

BEGIN EDIT

The error I am getting in the web browser (IE11 on Windows Server 2016) is:

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 suply the credentials required.

When I searched for this issue, I found the following question on StackOverflow: pg4admin 401 Unauthorized Error

That question describes my problem exactly. However, none of those answers resolved my issue. The tray application appears to be successfully binding to the correct ports (netstat -a -n appears to be correct), and there is nothing in the pgAdmin log file that looks suspicious. I will leave this question open, since fixing the port number seems like a reasonable thing to do, while I try to determine why pgAdmin isn't working.


Solution 1:

Your specific problem might have already been resolved, but...

It is possible to configure a fixed port for pgAdmin 4:

  1. Click on the pgAdmin 4 tray-icon
  2. Click "Configure..."
  3. Check the box labeled "Fixed Port Number?"
  4. Enter the desired port number in the field next to it

Screenshots:

  • pgAdmin 4 Configuration
  • Tray icon (on GNOME desktop)

Solution 2:

Ran into this problem on Windows Server 2016 with pgAdmin4 v3.5 - resolved it by setting "IE Enhanced Security Configuration" to OFF - can then immediately access the management pages (note - 'run as Administrator' was not required).

Solution 3:

Had the same issue in the following setup: Kubuntu 18, Firefox 64.0

What worked for me:

  1. Context menu > Copy server URL. That will give us an url of form:
    http://127.0.0.1:1234/?key=18ef03ff-d16a-43bc-af30-b20c66fbf452

  2. Navigate to that URL via browser (in my case Firefox worked well)


The following did not help:

  • Context menu > New pgAdmin 4 window...

  • Uninstall & install pgAdmin 4

  • Clear cookies for 127.0.0.1

  • Restart pgAdmin4

Hope this helps someone.