How to install pgAdmin 4 in desktop mode? The documentation only details server mode.
-
The docker version sure was a lot easier and faster way of installing PGAdmin4. I spent a lot of time to do it the old way that was in the readme file. The way to access it then is in a browser window, point it to 0.0.0.0:5050 and it comes up real good. It loads quite fast BUT when I try to create a server with it it keeps saying that Postgresql is NOT running, however in PGAdmin3 Postgresql is running fine. Have read many comments saying what a poor product it is so use at your own risk!!! – Gerald Brown May 15 '17 at 12:54
-
https://kiahosseini.github.io/help/2016/10/18/installing-pgadmin4-ubuntu-16.04.html – Dave Jarvis Aug 22 '17 at 00:41
-
2Only pgadmin3 is available on apt (ubuntu 16.04). Any idea how to open a request to Canonical to include pgadmin4 in apt packages? What's the process of requesting an "app" to be included in a package manager? – AlikElzin-kilaka Dec 26 '17 at 08:47
-
@AlikElzin-kilaka - check my answer below for the apt approach. – Muhamed Huseinbašić May 30 '18 at 13:31
-
If anyone just wants pgAdmin3 you can simply install it using the Ubuntu Software application that's on all Ubuntu installations. – Kyle Bridenstine Aug 22 '19 at 13:23
4 Answers
For pgAdmin 4 v4.21 on Ubuntu, according to the download page:
Install dependencies, create a virtual environment, download, install & configure
Using Python2.x
sudo apt-get install virtualenv python-pip libpq-dev python-dev
cd
virtualenv pgadmin4
cd pgadmin4
source bin/activate
pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.21/pip/pgadmin4-4.21-py2.py3-none-any.whl
Using Python3.6 (Preferred to avoid encoding related issues)
sudo apt-get install virtualenv python3-pip libpq-dev python3-dev
cd
virtualenv -p python3 pgadmin4
cd pgadmin4
source bin/activate
pip3 install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.21/pip/pgadmin4-4.21-py2.py3-none-any.whl
Configure
Override default paths and set it to single-user mode in the local configuration file:
nano lib/python2.7/site-packages/pgadmin4/config_local.py
For Python3.x:
nano lib/python3.6/site-packages/pgadmin4/config_local.py
Write:
import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgadmin/'))
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
SERVER_MODE = False
Run
python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
For Python3.x:
python3 lib/python3.6/site-packages/pgadmin4/pgAdmin4.py
Access
Access at http://localhost:5050
Exit
Exit with Ctrl-C
Run again
cd ~/pgadmin4
source bin/activate
python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
For Python3.6
#!/bin/bash
cd ~/pgadmin4
source bin/activate
python3 lib/python3.6/site-packages/pgadmin4/pgAdmin4.py
Make a shortcut
touch ~/pgadmin4/pgadmin4
chmod +x ~/pgadmin4/pgadmin4
nano ~/pgadmin4/pgadmin4
Write:
#!/bin/bash
cd ~/pgadmin4
source bin/activate
python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
For Python3.6
#!/bin/bash
cd ~/pgadmin4
source bin/activate
python3 lib/python3.6/site-packages/pgadmin4/pgAdmin4.py
Now you can just run it with a simpler command:
~/pgadmin4/pgadmin4
Python3 users
Replace [x] in Python3.6 with your respective version.
Conflict with pgAdmin 3 configuration
pgAdmin 4
will not start in the environment where pgAdmin 3
was previously installed and used because of incompatible configuration in the .pgadmin
directory. The simplest solution is to either clear that directory or tweak config_local.py
to point to a clean new .pgadmin4
directory.

- 9,313
-
-
Great and easy method, can you please add instructions to upgrade to newer versions too? I had to delete my old virtualenv and create new one, that was only way i knew. Thanks again. – Zia Ul Rehman Mughal Apr 15 '17 at 12:15
-
Added edit request for 4.1.5 (and noticed I wasn't logged in when I did so), in the meantime just make sure you use the 4.1.5 link: https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.5/pip/pgadmin4-1.5-py2.py3-none-any.whl – Olivercodes May 30 '17 at 21:37
-
7I'd like to add that so I can quickly run it, I added this to my ~/.bashrc :
alias pgadmin="source ~/pgadmin4/bin/activate && python ~/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py"
That way I can just type pgadmin and it launches, like it SHOULD out of the box. You listening pgadmin?
– light24bulbs Jun 13 '17 at 21:32 -
FYI this has changed with the release of pgAdmin 4 v2: https://www.pgadmin.org/docs/pgadmin4/dev/server_deployment.html#python – James Irwin Oct 12 '17 at 15:32
-
ftp link for v2.0 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v2.0/pip/pgadmin4-2.0-py2.py3-none-any.whl – cwhisperer Oct 22 '17 at 10:12
-
1Here is the correct link for FTP v2.1: https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v2.1/pip/pgadmin4-2.1-py2.py3-none-any.whl – Aïssa Jan 22 '18 at 12:42
-
Why when I start pgAdmin and trying to hit
http://localhost:5050
in the browser it opens the pgAdmin menu, but when I try to hithttp://127.0.0.1:5050
it is not working an throws exceptions in the terminal (or after 10 minutes waiting start to return Unauthorized status codes)? Does someone have idea? Thanks in advance! – DPM Feb 19 '18 at 22:47 -
1Could the hard linking to python3.6 dependency in the
python3 lib/python3.6/site-packages/pgadmin4/pgAdmin4.py
be removed/replaced? That way the answer would be more future proof. – paul23 Sep 04 '18 at 18:22 -
if you have fish , do
. bin/activate.fish
instead ofsource bin/activate
– goksel Dec 10 '18 at 19:33 -
A simpler command to launch the server is
python -m pgadmin4.pgAdmin4
. This avoids having to reference paths directly in the site-packages directory. – jpmc26 Mar 19 '19 at 17:53 -
1On Ubuntu 19.04 which comes with Python 3.7 swap out every occurence of 3.6 with 3.7 in the Python 3.x instructions. – Kalle Richter May 19 '19 at 09:15
-
These instructions worked for me till the execution part where it threw the error " from werkzeug import url_encode ImportError: cannot import name 'url_encode'". This is a problem due to using a later version of Werkzeug and can be fixed by downgrading it by running "pip install werkzeug==0.16.0". – Primal Pappachan Apr 22 '20 at 20:18
-
As per version 6.11 you need to add another config variable to config_local.py AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache') Or the application will throw exception that /var/lib/pgadmin/azurecredentialcache is not a directory – Dilyan Trayanov Jul 08 '22 at 07:14
Other option is to use docker and a docker image provided by thaJeztah - https://github.com/thaJeztah/pgadmin4-docker
$ docker run --rm -p 5050:5050 thajeztah/pgadmin4
Then to access a PostgreSQL DB instance from within pgadmin4 you should use the IP of the host instead of localhost and 127.0.0.1 since Docker will map those to the container itself.
The IP of a dockerised DB instance could be found with 2 steps:
find the container ID of your db with:
docker ps
inspect the container_name to find its ip with:
docker inspect <ID from previous step>
you are looking for something like "IPAddress": "172.18.0.3"

- 9,313

- 631
-
1How can you make it see a dockerized postgres? localhost/127.0.0.1/container id did not work for me. – ampofila Apr 18 '17 at 12:04
-
1Can we set the IP static i.e. we don't have to update our application to point to new docker container IP every time we restart it – Nam G VU Sep 16 '17 at 04:45
-
Nice, added a chromium application shortcut, and it's almost like having the actual application back- – chrismarx Jan 22 '18 at 15:26
-
Other way to connect the host database: https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach – qmn1711 Sep 24 '18 at 13:17
On Ubuntu 16.04 you can install pgadmin4
with
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add
sudo apt update
sudo apt install pgadmin4
I have tested this on 16.04.

- 6,180
- 21
- 70
- 103

- 1,258
- 3
- 14
- 19
-
Okay, one another thing i want to know that how do i start if i installed it on server. – Akhilendra Aug 03 '18 at 07:27
-
1For Ubuntu based distros like Mint you may want to replace the
$(lsb_release -cs)
with the version of Ubuntu it's based on. For example, Mint Sarah (version 18) is based on Xenial and looks like this:sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
– aggregate1166877 Sep 28 '18 at 22:47 -
3It looks like the ultimate solution, at least for Ubuntu +16.xx. Thanks ! – Bonlou Nov 19 '18 at 10:47
Finally, pgAdmin team created an apt package for pgAdmin4
It is supported on:
- Debian 9 (Stretch), 10 (Buster)
- Ubuntu 16.04 (Xenial), 18.04 (Bionic), 19.10 (Eoan), 20.04 (Focal)
Now to install it you have to setup the the pgAdmin 4 offical repository, then you can install it
Setup the repository
Install the public key for the repository (if not done previously)
curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add
Create the repository configuration file:
sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
Install pgAdmin4
You can install both Desktop and Web modes:
sudo apt install pgadmin4
For Desktop only:
sudo apt install pgadmin4-desktop
For Web only:
sudo apt install pgadmin4-web

- 137
- 5
-
I have installed the desktop version (6.1) and when entering I see there is a newer version (6.3) however when I run "sudo apt install pgadmin4-desktop" I still get "pgadmin4-desktop is already the newest version (6.1).". How can I update it to 6.3 ? – thanos.a Dec 17 '21 at 08:11
-
@thanos.a try
sudo apt update
first, thensudo apt install pgadmin4-desktop
– Hazem Dec 17 '21 at 21:01 -
It used to tell me that I am using the latest version 6.1. Once I updated my Ubuntu version from 20.04 to 21.04, I was able to install 6.3 – thanos.a Dec 20 '21 at 08:53