How to Install pgAdmin 4 on Rocky, Alma, Ubuntu and Debian

Install pgAdmin 4 on Rocky Linux and AlmaLinux 8, 9 or 10, Ubuntu or Debian: add the official repo, install pgadmin4-web, run setup-web.sh and log in.

Quick answer. pgAdmin 4 is not in the distro repos. Add the pgAdmin project’s repo, install pgadmin4-web, then run the setup script:

# Rocky Linux / AlmaLinux 8, 9, 10
sudo rpm -i https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-2-1.noarch.rpm
sudo dnf install -y pgadmin4-web

# Ubuntu / Debian
sudo apt install -y curl gpg lsb-release
curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
sudo apt install -y pgadmin4-web

# Both
sudo /usr/pgadmin4/bin/setup-web.sh

Then open http://SERVER_IP/pgadmin4.

PGAdmin is a web-based GUI tool used to interact with the Postgres database sessions, both locally and remote servers as well. It is an open-source, powerful, and feature-rich graphical user interface (GUI) administration and management tool for the PostgreSQL database. It provides a powerful user interface that enables you to easily create, manage, maintain and use database objects, by both beginners and experienced Postgres users alike.

In this guide we will install pgAdmin 4 (9.19 at the time of writing) in web mode on the RHEL family and on Ubuntu and Debian, then add a server connection. The steps were tested on Rocky Linux 9 and Ubuntu 24.04.

Prerequisites

Older releases (Ubuntu 20.04, Debian 11, CentOS 7) have dropped off the repos. Their last packages are on pgadmin-archive.postgresql.org, which cannot be used as a repo.

Related Content

Desktop or web mode

pgAdmin is available in both desktop and web mode. If you are running postgres on a local desktop system, the desktop mode is recommended, otherwise the web mode will work just fine. In my case I will be installing the web mode. The package names are the same on every distro:

PackageInstalls
pgadmin4-webWeb mode, served by Apache at /pgadmin4
pgadmin4-desktopDesktop app only
pgadmin4Both

Rocky Linux and AlmaLinux (8, 9 and 10)

Update the system

Before proceeding, let us ensure that our server has updated packages:

sudo dnf upgrade --refresh -y

Set up the pgAdmin 4 repo

The pgadmin 4 package is not found in the default Rocky Linux or AlmaLinux repositories. Install the pgAdmin repo package, which works on EL 8, 9 and 10 and will keep track of updates for future pgadmin releases (EL 8 stops at pgAdmin 9.14):

sudo rpm -i https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-2-1.noarch.rpm

If you have an older pgAdmin repo package installed, remove it first with sudo rpm -e pgadmin4-redhat-repo.

Install pgAdmin 4

To install web mode only:

sudo dnf install -y pgadmin4-web

Use pgadmin4-desktop or pgadmin4 instead for desktop mode or both. The web package pulls in Apache (httpd).

Configure web mode

Once you have the web mode installed, you need to configure it before using. The setup script creates an initial user, configures SELinux and starts Apache:

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

This is the output on my system:

Setting up pgAdmin 4 in web mode on a Redhat 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: admin@citizix.com
Password:
Retype password:
pgAdmin 4 - Application Initialisation
======================================

Creating storage and log directories...
Configuring SELinux...
The Apache web server is not running. We can enable and start the web server for you to finish pgAdmin 4 installation. Continue (y/n)? y
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Apache successfully enabled.
Apache successfully started.
You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4

If firewalld is running, open HTTP so other machines can reach it. pgAdmin web mode serves its login, and the database passwords it stores, over plain HTTP. Open port 80 only to the address you work from (replace 203.0.113.10), and put TLS or a VPN in front of it before exposing it any wider.

sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" service name="http" accept'
sudo firewall-cmd --reload

Ubuntu and Debian

Update the system

sudo apt update
sudo apt upgrade -y

Set up the pgAdmin 4 repo

The pgadmin 4 package is not found in the default Ubuntu or Debian repositories. Install the public key for the repository:

sudo apt install -y curl gpg lsb-release
curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg

Create the repository configuration file and update the repos. lsb_release -cs fills in your release codename (noble, bookworm and so on):

sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

Older guides, including earlier versions of this one, use apt-key add. apt-key is deprecated (and removed in Debian 13); the signed-by keyring above replaces it.

Install pgAdmin 4

sudo apt install -y pgadmin4-web

Use pgadmin4-desktop or pgadmin4 instead for desktop mode or both. The web package pulls in Apache (apache2).

Configure web mode

Run the setup script to create the admin user and configure Apache:

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

You’ll be prompted for the email address and password of the initial admin account, then whether to configure Apache and whether to restart it. Answer y to both:

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: admin@citizix.com
Password:
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 http://127.0.0.1/pgadmin4

If ufw is enabled, allow HTTP. pgAdmin web mode serves its login, and the database passwords it stores, over plain HTTP. Open port 80 only to the address you work from (replace 203.0.113.10), and put TLS or a VPN in front of it before exposing it any wider.

sudo ufw allow from 203.0.113.10 to any port 80 proto tcp

Access pgAdmin 4 and add a server

Now you can access the pgAdmin 4 web interface. Open a web browser and point it to http://127.0.0.1/pgadmin4 or http://SERVER_IP/pgadmin4.

The pgadmin 4 login page will load prompting you for the email address and password that you set earlier. After a successful login, you will land at the pgAdmin 4 dashboard.

To connect to a database server:

  1. Click Add New Server.
  2. On the General tab, enter a name (e.g. “Production PostgreSQL”).
  3. On the Connection tab, enter:
    • Host name/address: localhost (or your PostgreSQL server IP)
    • Port: 5432
    • Maintenance database: postgres
    • Username and Password: your PostgreSQL user
  4. Click Save.

Under the Browser, click on the Servers to expand. You should have the server you added. It will show the databases, roles, and tablespaces. Click a database to view its dashboard and performance metrics.

Frequently Asked Questions (FAQ)

What is pgAdmin 4?

pgAdmin 4 is a web-based administration tool for PostgreSQL. It provides a GUI for creating databases, managing users, running SQL queries, viewing performance metrics, and more. It can connect to local or remote servers.

What is the difference between pgAdmin desktop and web mode?

Desktop mode (pgadmin4-desktop) runs as a standalone desktop application. Web mode (pgadmin4-web) runs via Apache and is accessible from any browser. For servers, use web mode; for local development on a desktop, either works.

Where is pgAdmin 4 installed?

The application lives in /usr/pgadmin4/. The web interface is served by Apache at /pgadmin4. Its configuration database and storage are in /var/lib/pgadmin/ and logs in /var/log/pgadmin/. The setup script configures Apache automatically.

How do I access pgAdmin 4 from another machine?

If Apache is listening on all interfaces, use http://your-server-ip/pgadmin4. For production, put it behind TLS (for example an NGINX reverse proxy with Let’s Encrypt) and restrict access with a VPN or firewall rules.

Can I install pgAdmin 4 on an ARM server?

Not from the repos in this guide: they publish x86_64 / amd64 packages only. Use the official dpage/pgadmin4 container image, which has ARM builds. See How to run PGAdmin 4 Using Docker and Docker-Compose.

Wrapping up

We installed pgAdmin 4 in web mode on Rocky Linux and AlmaLinux with dnf, and on Ubuntu and Debian with apt, ran setup-web.sh to create the admin user and configure Apache, and added a server connection.

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy