How to install pgAdmin 4 on Debian 11

In this tutorial guide, I will be taking you through the installation of pgAdmin 4 on Debian 11.

pgAdmin 4 is a free and open-source management tool for Postgres. Its desktop runtime written in NWjs allows it to run standalone for individual users, or the web applications code may be directly deployed on a web server for use by the web browser.

pgAdmin 4 is a complete rewrite of pgAdmin, built using Python and Java

New features of pgAdmin 4

The following new features were introduced for the latest release of 6.2. these features are mostly for bug fixes.

  • It added support for Aggregate and Operator node in view-only mode
  • It ensures that users will be able to modify the REMOTE_USER environment variable as per their environment by introducing the new config parameter WEBSERVER_REMOTE_USER.

You can refer to pgAdmin 4 documentation for more concerning the bug fixes introduced with the current version 6.2.


  1. Have a PostgreSQL server running on Debian 11
  2. Debian 11 server
  3. User with sudo privileges
  4. Access to the internet.

Table of Contents

  1. Update Debian 11 repositories
  2. Install PostgreSQL server
  3. Install the public key for the repository
  4. Create repository configuration files
  5. Install pgAdmin 4
  6. Configure web server
  7. Conclusion

1. Run Debian 11 updates

In order to begin our installation, we will first update our repositories in order to make them up to date. on your terminal run the following commands;

$ sudo apt update
$ sudo apt upgrade -y

The commands above will update the system and upgrade packages accordingly.

2. Install PostgreSQL 14 server

To install PostgreSQL 14 server, follow the following steps;

Create a directory

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

After you have added the following script, now you can add the GPG key.

Import GPG Key

Import the GPG key pair in order to for it to be signed correctly. Use the following command to import the key.

$ wget --quiet -O - | sudo apt-key add -

You will get an ok as output meaning you have successfully added the GPG key.

Next, we will run the updates.

$ sudo apt update

Now we can install the latest version of PostgreSQL

Install PostgreSQL 14 on Debian 11

Use the following command to install a specific version of PostgreSQL

$ sudo apt install postgresql-14 -y

Sample output will be as follows

Creating config file /etc/postgresql-common/createcluster.conf with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Created symlink /etc/systemd/system/ →
Setting up postgresql-14 (14.5-0ubuntu0.22.04.1) ...
Creating new PostgreSQL cluster 14/main ...
/usr/lib/postgresql/14/bin/initdb -D /var/lib/postgresql/14/main --auth-local pe
er --auth-host scram-sha-256 --no-instructions
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "C.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

We have successfully installed PostgreSQL. We can proceed to install pgAdmin 4.

3. Add public key for pgAdmin 4

Use the following command to add the public key to your repository.

$ curl -fsSL | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/pgadmin.gpg

4. Create pgAdmin 4 repository file

Then we can go ahead and add a configuration file that can aid in pgAdmin 4 installation.

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

Update your system now for the changes to take effect before installing the pgAdmin 4.

5. Install pgAdmin 4

We will install pgAdmin 4 for both web and desktop environments.

$ sudo apt install pgadmin4

Sample output from the installation

Created symlink /etc/systemd/system/ → /lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/ → /lib/systemd/system/apache-htcacheclean.service.
Setting up libxaw7:amd64 (2:1.0.13-1.1) ...
Setting up libapache2-mod-wsgi-py3 (4.7.1-3build2) ...
apache2_invoke: Enable module wsgi
Setting up x11-xserver-utils (7.7+8build1) ...
Setting up x11-utils (7.7+5build1) ...
Setting up pgadmin4-web (6.2) ...
Setting up pgadmin4 (6.2) ...
Setting up liblwp-protocol-https-perl (6.10-1) ...
Setting up libwww-perl (6.53-1) ...
Setting up libxml-parser-perl:amd64 (2.46-2) ...                           

Having completed the installation of pgAdmin 4 we now need to connect with our Apache web server

6. Configure Apache for pgAdmin 4

Let’s serve our pgAdmin 4 using an Apache webserver.

To do so we need to initiate the Apache webserver configuration with the following script.

$ sudo /usr/pgadmin4/bin/

You will need to configure the email address and password to continue using it.

The following is the output you will get.

Setting up pgAdmin 4 in web mode on a Debian based platform...
Creating configuration database...
NOTE: Configuring authentication for SERVER mode.

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

Email address: [email protected]
Retype password:
pgAdmin 4 - Application Initialisation

Creating storage and log directories...
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

To access pgadmin 4 from the browser go to this web address http://<your_server_IP>/pgadmin4

nextgentips: pgAdmin4
nextgentips: pgAdmin4

Use the credentials you set above to login

pgAdmin Dashboard
pgAdmin Dashboard


We have successfully installed pgAdmin 4 in our system. Go ahead and experiment more to gain more insight.

About Kipkoech Sang

I am a technology enthusiast who loves to share gained knowledge through offering daily tips as a way of empowering others. I am fan of Linux and all other things open source.
View all posts by Kipkoech Sang →

Leave a Reply

Your email address will not be published.