Thread: Issue with pgAdmin 4 Login Behind NGINX Reverse Proxy at /pgadmin4 Path
Hi,
I've installed pgAdmin 4 on my Linux server and configured it behind Gunicorn and NGINX, accessible at:https://domain.com/pgadmin4/
.
The login page loads correctly. However, after entering valid credentials, I'm redirected back to the login page without any error message. Occasionally, I see a CSRF token error, which disappears after a page refresh, but the login still fails.
In the browser console or network tab, I sometimes see 401
errors or issues loading static assets.
Here's the NGINX configuration I'm currently using to reverse proxy pgAdmin via a Unix socket:
nginxlocation /pgadmin4/ { proxy_pass http://unix:/tmp/pgadmin4.sock:/; # Proxy headers proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # Inform pgAdmin it's served under a subpath proxy_set_header X-Script-Name /pgadmin4; # Optional: timeouts and static asset handling proxy_read_timeout 300; proxy_connect_timeout 60; }
Could you please advise:
Is there something wrong with the proxy setup?
Do I need to handle static assets or cookies differently when using a subpath (
/pgadmin4
)?Are there any additional settings required in the pgAdmin config to work correctly behind a sub-URI with NGINX?
Thanks in advance for your guidance.
Re: Issue with pgAdmin 4 Login Behind NGINX Reverse Proxy at /pgadmin4 Path
Hi,
I've installed pgAdmin 4 on my Linux server and configured it behind Gunicorn and NGINX, accessible at:
https://domain.com/pgadmin4/
.The login page loads correctly. However, after entering valid credentials, I'm redirected back to the login page without any error message. Occasionally, I see a CSRF token error, which disappears after a page refresh, but the login still fails.
In the browser console or network tab, I sometimes see
401
errors or issues loading static assets.Here's the NGINX configuration I'm currently using to reverse proxy pgAdmin via a Unix socket:
nginxlocation /pgadmin4/ { proxy_pass http://unix:/tmp/pgadmin4.sock:/; # Proxy headers proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # Inform pgAdmin it's served under a subpath proxy_set_header X-Script-Name /pgadmin4; # Optional: timeouts and static asset handling proxy_read_timeout 300; proxy_connect_timeout 60; }
Could you please advise:
Is there something wrong with the proxy setup?
Do I need to handle static assets or cookies differently when using a subpath (
/pgadmin4
)?Are there any additional settings required in the pgAdmin config to work correctly behind a sub-URI with NGINX?
Thanks in advance for your guidance.
Re: Issue with pgAdmin 4 Login Behind NGINX Reverse Proxy at /pgadmin4 Path
Thanks, it worked.
I am facing an issue when I try to access the pgadmin of https after logging in; it shows a blank page. Can you please help me figure it out?
This is the config I am using for the proxy in HTTPS and HTTP vhblock
location = /pgadmin4 { rewrite ^ /pgadmin4/; }
location ^~ /pgadmin4/ {
proxy_pass http://unix:/tmp/pgadmin4.sock;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Script-Name /pgadmin4;
proxy_http_version 1.1;
proxy_read_timeout 300;
proxy_connect_timeout 60;
}
In the browser console of I am getting this error.
Object { message: "Request failed with status code 401", name: "AxiosError", code: "ERR_BAD_REQUEST", config: {…}, request: XMLHttpRequest, response: {…}, status: 401, stack: "".....
Hi,You can use the command 'update-user' for user update.To explore more options, you can use the command below with pgadmin venv.`python3.12 setup.py update-user --help `
Typical command would be -
`python3.12 setup.py update-user <user_id> --password <new_password> --role Administrator --sqlite-path <pgadmin_db_path>`
Thanks,Yogesh MahajanEnterpriseDBOn Sat, Jun 14, 2025 at 5:09 PM Shakir Idrisi <shakir@webuzo.com> wrote:Hi,I hope you're doing well.pgAdmin is now working properly. Earlier, I ran the setup-db command and set the admin username and password.Now, after reinstalling pgAdmin, I noticed that the data directory (including pgadmin.db) was not removed. I would like to either reuse the old admin password or reset it if needed.Is there a way to reset the admin user's password using a command in this case?Your guidance would be greatly appreciated.Thank you for your help.On Tue, Jun 10, 2025, 9:57 PM Shakir Idrisi <shakir@webuzo.com> wrote:Ok, I will check.On Tue, Jun 10, 2025, 5:26 PM Yogesh Mahajan <yogesh.mahajan@enterprisedb.com> wrote:Hi,I could reproduce the error when I have multiple workers. Maybe you can try restarting the Guicorn service.Can you please try once in the private browser window?Thanks,Yogesh MahajanEnterpriseDBOn Tue, Jun 10, 2025 at 3:54 PM Shakir Idrisi <shakir@webuzo.com> wrote:HI,
I have used this command, and I have created a systemd file to start and stop the service.
ExecStart=/var/w-data/pgadmin4/pgadmin_venv/bin/gunicorn \
--workers 1 \
--threads=25 \
--bind unix:/tmp/pgadmin4.sock \
--chdir /var/w-data/pgadmin4/pgadmin_venv/lib/python3.11/site-packages/pgadmin4 \
--umask 007 \
pgAdmin4:app
Also, when I try multiple times then it will log in and show a blank dashboard, or sometimes it will show a dashboard but not work properly. In the console log, I see the following errorOn Tue, Jun 10, 2025 at 3:26 PM Yogesh Mahajan <yogesh.mahajan@enterprisedb.com> wrote:Hi,Can you please share your guicorn command?How many workers are you spawning? It should be 1.Thanks,Yogesh MahajanEnterpriseDBOn Tue, Jun 10, 2025 at 12:34 PM Shakir Idrisi <shakir@webuzo.com> wrote:Hi,
I've installed pgAdmin 4 on my Linux server and configured it behind Gunicorn and NGINX, accessible at:
https://domain.com/pgadmin4/
.The login page loads correctly. However, after entering valid credentials, I'm redirected back to the login page without any error message. Occasionally, I see a CSRF token error, which disappears after a page refresh, but the login still fails.
In the browser console or network tab, I sometimes see
401
errors or issues loading static assets.Here's the NGINX configuration I'm currently using to reverse proxy pgAdmin via a Unix socket:
nginxlocation /pgadmin4/ { proxy_pass http://unix:/tmp/pgadmin4.sock:/; # Proxy headers proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # Inform pgAdmin it's served under a subpath proxy_set_header X-Script-Name /pgadmin4; # Optional: timeouts and static asset handling proxy_read_timeout 300; proxy_connect_timeout 60; }
Could you please advise:
Is there something wrong with the proxy setup?
Do I need to handle static assets or cookies differently when using a subpath (
/pgadmin4
)?Are there any additional settings required in the pgAdmin config to work correctly behind a sub-URI with NGINX?
Thanks in advance for your guidance.