pgAdmin 4 is the leading open-source management tool for PostgreSQL databases. It provides a powerful web-based interface for managing your PostgreSQL servers, running queries, monitoring performance, and handling routine database administration tasks. This guide covers installing pgAdmin 4 (version 9.13) in web mode on Ubuntu 24.04 and Ubuntu 22.04.

pgAdmin 4 web mode runs as a web application served through Apache. You access it from any browser on your network – no desktop environment needed on the server. This makes it ideal for managing remote PostgreSQL instances from a single dashboard.

Prerequisites

Before you begin, confirm the following requirements are met:

  • Ubuntu 24.04 or Ubuntu 22.04 server (fresh or existing)
  • Root or sudo access on the server
  • PostgreSQL installed and running – see our guide on installing PostgreSQL on Ubuntu
  • Ports 80 and 443 open in the firewall (for web access)
  • A working internet connection to download packages

Step 1: Update your system

Start by updating the package index and upgrading existing packages.

sudo apt update && sudo apt upgrade -y

Step 2: Add the pgAdmin 4 APT repository

pgAdmin 4 is not available in the default Ubuntu repositories. You need to add the official pgAdmin repository maintained by the PostgreSQL Global Development Group.

First, install the required prerequisite packages:

sudo apt install -y curl gpg apt-transport-https

Import the GPG signing key for the repository:

curl -fsSL https://www.pgadmin.org/static/packages_pgadmin_org.pub \
  | sudo gpg --dearmor -o /usr/share/keyrings/pgadmin-keyring.gpg

Add the pgAdmin 4 repository to your APT sources. For Ubuntu 24.04 (Noble):

echo "deb [signed-by=/usr/share/keyrings/pgadmin-keyring.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/noble pgadmin4 main" \
  | sudo tee /etc/apt/sources.list.d/pgadmin4.list

For Ubuntu 22.04 (Jammy), replace noble with jammy in the command above.

Update the package index to pull metadata from the new repository:

sudo apt update

Step 3: Install pgAdmin 4 web mode

Install the pgadmin4-web package. This installs pgAdmin 4 in web mode along with Apache as the web server.

sudo apt install -y pgadmin4-web

Verify the installation

Confirm pgAdmin 4 is installed and check the version:

dpkg -l pgadmin4-web

You should see version 9.13 (or later) in the output.

Step 4: Run the pgAdmin 4 web setup script

pgAdmin 4 ships with a setup script that configures the web application. It creates the initial admin user account and sets up Apache.

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

The script will prompt you to provide:

  • Email address – this is the login username for the pgAdmin web interface
  • Password – set a strong password for the admin account

The script also configures Apache and restarts the service automatically. Sample output:

pgAdmin 4 web setup script output on Ubuntu

Step 5: Configure the firewall

If UFW (Uncomplicated Firewall) is active on your server, allow HTTP and HTTPS traffic:

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload

Verify the rules are in place:

sudo ufw status

If you use iptables directly instead of UFW:

sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT

Step 6: Access the pgAdmin 4 web interface

Open your web browser and navigate to:

http://your-server-ip/pgadmin4

You will see the pgAdmin 4 login page. Enter the email address and password you created during the setup step.

pgAdmin 4 login page on Ubuntu

After successful login, you land on the pgAdmin 4 dashboard:

pgAdmin 4 dashboard after login

Step 7: Add a PostgreSQL server to pgAdmin 4

With pgAdmin 4 running, the next step is to connect it to your PostgreSQL server.

Click Add New Server on the dashboard, or go to Object > Register > Server.

pgAdmin 4 add new server option

In the General tab, give the server a descriptive name. Then switch to the Connection tab and fill in:

  • Host name/address – the IP or hostname of your PostgreSQL server (use localhost or 127.0.0.1 if PostgreSQL runs on the same server)
  • Port – default is 5432
  • Maintenance database – typically postgres
  • Username – your PostgreSQL user (e.g., postgres)
  • Password – the password for that PostgreSQL user
pgAdmin 4 server connection settings

Click Save. pgAdmin 4 will connect to your PostgreSQL instance and display the server tree in the left panel.

pgAdmin 4 connected to PostgreSQL server

You can now browse databases, run SQL queries using the Query Tool, monitor server activity, and manage all aspects of your PostgreSQL deployment.

pgAdmin 4 query tool interface

Production recommendations

For production environments, apply these hardening measures:

  • Enable SSL/TLS – configure Apache with a valid SSL certificate (Let’s Encrypt works well). Never expose pgAdmin over plain HTTP in production.
  • Use a reverse proxy – place Nginx or Apache as a reverse proxy in front of pgAdmin for better control over headers, rate limiting, and access restrictions.
  • Restrict access by IP – limit who can reach the pgAdmin URL using firewall rules or Apache’s Require ip directive.
  • Enable two-factor authentication – pgAdmin 4 supports TOTP-based 2FA. Enable it from File > Preferences > User Management.
  • Keep pgAdmin updated – run sudo apt update && sudo apt upgrade pgadmin4-web regularly to get security patches.

Conclusion

You now have pgAdmin 4 installed and running in web mode on your Ubuntu 24.04 server. The web interface is accessible at http://your-server-ip/pgadmin4, and you can connect to any PostgreSQL server on your network. For a production setup, prioritize enabling SSL and restricting access by IP.

For complete documentation on pgAdmin 4 features and configuration options, refer to the official pgAdmin 4 documentation. The PostgreSQL documentation is also a valuable resource for database administration tasks.

Related guides

6 COMMENTS

  1. Thanks alot! Very useful.

    Is there a way to change the password which was given during the configuration of apache?

LEAVE A REPLY

Please enter your comment!
Please enter your name here