How to Install pgAdmin 4 on Ubuntu

install pgadmin4 ubuntu

pgAdmin is a useful databases administration and development tool that allows you to manage your PostgreSQL databases. You can use it to manage your databases, write SQL queries and even design database architecture. Let us take a look at how to install pgAdmin 4 on Ubuntu


How to Install pgAdmin 4 on Ubuntu

Here are the steps to install pgAdmin 4 on Ubuntu. Before we proceed, please ensure you have:

  • Installed Apache web server on a Ubuntu System
    sudo apt update
    sudo apt install apache2
  • Installed PostgreSQL on your Ubuntu system. Here’s the command
    sudo apt-get install postgresql


1. Install pgAdmin and its dependencies

First, lets’ update Ubuntu’s packages so that pgAdmin’s installation goes smoothly

$ sudo apt update


Import Repository Key

$ sudo apt-get install curl ca-certificates
$ curl | sudo apt-key add -


Next, you need to create /etc/apt/sources.list.d/pgdg.list, add the location of the repo (appropriate for your distribution) to pgdg.list. Here’s a shorthand command that does all of it. It will find out codename of your distribution and add the repo to your source.list file.

$ sudo sh -c 'echo "deb $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'



Update package lists and install packages

$ sudo apt-get update
$ sudo apt-get install postgresql-11 pgadmin4


This will install pgadmin4 on Apache Server in Ubuntu


2. pgAdmin Configuration

From pgAdmin 4.2 onwards, pgAdmin is installed in server mode, by default.

The installation will create a config file for pgAdmin at


Please DO NOT update this file. Instead create a new file

$ cd /lib/python3.6/site-packages/pgadmin4
$ sudo nano


In your editor, add the following lines to the file

LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'


LOG_FILE: location of pgAdmin’s log files
SQLITE_PATH: location of user data, which pgAdmin stores in an SQLite db.
SESSION_DB_PATH: location of sessions db.
STORAGE_DIR: location of storage data
SERVER_MODE: tells pgAdmin to run in server mode, instead of desktop mode


Save and close the file.


Run the file to start the setup

$ sudo python


You’ll be asked to enter the email address and password for initial pgAdmin account, that you can use to login later on.

. . .
Enter the email address and password to use for the initial pgAdmin user account:

Email address:
Retype password:



Finally, change the ownership of folder locations mentioned in file above

$ sudo chown -R www-data:www-data /var/lib/pgadmin4/
$ sudo chown -R www-data:www-data /var/log/pgadmin4/



3. Apache Configuration

We’ll setup a virtual host in Apache to host pgAdmin. Go to site-available directory of your Apache installation

$ cd /etc/apache2/sites-available/


Create a new file called pgadmin.conf in it to configure your pgAdmin server

$ sudo nano /etc/apache2/sites-available/pgadmin4.conf


<VirtualHost *>
 ServerName your_server_ip

 WSGIDaemonProcess pgadmin processes=1 threads=25 python-home=/home/sammy/environments/my_env
 WSGIScriptAlias / /lib/python3.6/site-packages/pgadmin4/pgAdmin4.wsgi

 <Directory "/lib/python3.6/site-packages/pgadmin4/">
  WSGIProcessGroup pgadmin
  WSGIApplicationGroup %{GLOBAL}
  Require all granted


If you are using Apache older than v2.4, then replace

Require all granted


Order deny,allow
Allow from all


Next, disable the default virtual host file

$ sudo a2dissite 000-default.conf

Enable pgadmin4.conf

$ sudo a2ensite pgadmin4.conf


Test Apache config file

$ apachectl configtest


If everything is properly configured, you’ll see “Syntax OK” message. If you see an error, open the pgadmin.conf file, check the IP address as well as the file paths (shown in bold)

If there are no errors, start apache to apply changes

$ sudo systemctl restart apache2


4. Accessing pgAdmin

Open your web browser and go to http://your_server_ip

You’ll see a similar screen as shown below where you can login with the credentials you had saved earlier, in step 2.

pgadmin login blank


After login, you will see a welcome screen

pgadmin welcome page


Congratulations! You have installed pgAdmin 4 on Ubuntu. Now you can use it to create database connections, and manage your databases.

About Sreeram Sreenivasan

Sreeram Sreenivasan is the Founder of Ubiq, a business dashboard & reporting platform for small & medium businesses. Ubiq makes it easy to build business dashboards & reports for your business. Try it for free today!