This is a quickstart guide that includes the part how to connect pgAdmin4 to your local postgresql install by registering your server after installing PostgreSQL and pgAdmin4.

Read on.

Install PostgreSQL

Ubuntu Install

sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
sudo systemctl start postgresql.service

Update/Create PostgreSQL User

At this stage the PostgreSQL install process will have created a system user called ‘postgres‘, which matches the database username ‘postgres‘.

We need to change to sudo into that system user to change the database password.

sudo -i -u postgres
[email protected]:~$ psql
psql (14.5 (Ubuntu 14.5-0ubuntu0.22.04.1))
Type "help" for help.

postgres=# \password
Enter new password for user "postgres": 
Enter it again: 

You should now have changed the password for user ‘postgres’, remember this for later.

Install pgAdmin4

Create Virtual Environment

Going to need to create a venv for this.
Create a directory of your own choice and location, somewhere where you usually keep your virtual envs.
Run the following command to create a venv.

python3 -m venv pgadmin4env
source pgadmin4env/bin/activate

Pip Install Of pgAdmin4

Install the latest pgadmin, you can check for the latest whl file here

pip install

Create a config file at the following location within your venv directory,

nano ./pgadmin4env/lib/python3.10/site-packages/pgadmin4/

with the following content.

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')
AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR,'azurecredentialcache')

Start pgAdmin4

Start pgAdmin4 as a background process by calling the pgadmin4 binary inside your venv.


Register Your Local PostgreSQL

You will find that you can access pgAdmin at ‘

Right click on the server group ‘Servers‘, and click through ‘Register‘ and then ‘Server…

Give your server a name,

Under connection add the hostname, in my case localhost.
Also, notice that the user ‘postgres‘ is already prefilled.
Use the password you created earlier and click ‘Save‘.

You should now see that pgAdmin4 is now connected to, and displaying your local postgreSQL information.

Useful Notes

Change To Ubuntu Postgres User

sudo -i -u postgres

Check Connection

[email protected]:~$ \conninfo

Connect To PSQL console

[email protected]:~$ psql
psql (14.5 (Ubuntu 14.5-0ubuntu0.22.04.1))
Type "help" for help.


Change A Users Password

postgres=# \password username
Enter new password for user "username": 
Enter it again: 
%d bloggers like this: