How To Install pgAdmin 4 on Ubuntu 22.04

Estimated reading: 3 minutes 253 views

This post has been written primarily to guide new users on how to install pgAdmin 4 on Ubuntu 22.04|20.04|18.04 Linux system. pgAdmin is a feature-rich and open-source PostgreSQL administration and development platform that runs on Linux, Unix, Mac OS X, and Windows.

With pgAdmin, you can manage PostgreSQL database servers, from version 9.2 using an intuitive and powerful web interface.

Refer to the above guides and official pgAdmin documentation for platforms different from the ones shared. If you’re running an Ubuntu system or Linux Mint, this guide will work for you.

The one requirement for the installation of pgAdmin4 on Ubuntu is a PostgreSQL server. You can choose to go with any version of PostgreSQL server >=9.6. We have guides that can be used as a reference while installing the PostgreSQL database server.

Having completed the installation of the PostgreSQL database server on Ubuntu, proceed to install and initiate pgAdmin4 on the system.

https://youtu.be/aCGq381XoE4

Step 1: Add pgAdmin4 repository

The pgAdmin packages for all Debian-based Linux operating systems are available from the pgAdmin APT repository. In this step, we will add the repository to our Ubuntu system.

curl  -fsSL https://www.pgadmin.org/static/packages_pgadmin_org.pub | gpg --dearmor -o /etc/apt/trusted.gpg.d/pgadmin.gpg

Use the next command given to add the pgAdmin repository to your Ubuntu system:

sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list'

You can check the contents of the repository file created using the following command:

$ cat /etc/apt/sources.list.d/pgadmin4.list
deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/bullseye pgadmin4 main

Step 2: Install pgAdmin4 on Ubuntu

Finally, update the package lists.

apt update

To install pgAdmin4 packages on Ubuntu 22.04|20.04|18.04 system, run these commands, providing the correct version number:

apt install pgadmin4

Hit the y key to continue with the installation ofpgAdmin4 on Ubuntu 22.04

Apache service should have been started after installation.

Step 3: Configure Apache Server for pgAdmin4

Initiate Apache web server configuration.

/usr/pgadmin4/bin/setup-web.sh

This will require you to input the pgadmin4 user email address and set the password:

Agree on the configuration of the Apache Web server.

We can now configure the Apache Web server for you. This involves enabling the wsgi module and configuring the pgAdmin 4 application to mount at /pgadmin4. Do you wish to continue (y/n)? y
The Apache web server is running and must be restarted for the pgAdmin 4 installation to complete. Continue (y/n)? y
Apache successfully restarted. You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4

Step 4: Access pgAdmin 4 Web interface

If you have a UFW firewall configured, allow http and https traffic.

ufw allow http
ufw allow https

Open your browser and http://[ServerIP_or_domain]/pgadmin4.

Login by using a set email address and password.

Wait for a few seconds for initialization to complete.

On the first page of pgAdmin, add a PostgreSQL server to administer with pgAdmin by clicking on “Add New Server”. This can be a local or a remote PostgreSQL server.

Under the “General” section, give the server a name & description.

Under the “Connection” tab, provide access details – DB host, DB user, and Password.

When done, Click the Save button to save the configurations. If you were successful in adding the server, the name will appear in the left sidebar.

Select the server to see the database summary information and make changes. Learn more on how to use pgAdmin from the documentation page.