pgAdmin 4 is a web-based GUI for managing PostgreSQL databases. It supports PostgreSQL 9.2+ and runs on Linux, macOS, and Windows. You can use it to create databases, manage users, run queries, view performance metrics, and more. In this guide you install pgAdmin 4 in web mode on Ubuntu 22.04 LTS, configure it with Apache, and connect to a PostgreSQL server.
In this guide you’ll:
- Add the pgAdmin APT repository and install
pgadmin4-web - Run the setup script to create an admin user and configure Apache
- Access the web interface and add a PostgreSQL server connection
Prerequisites:
- Ubuntu 22.04 LTS with sudo access.
- PostgreSQL installed (9.2 or later). If not, see How to Install and Configure Postgres 14 on Ubuntu 22.04 first.
Related: Postgres user and database permissions · Postgres 14 on Debian 11 · Postgres 14 with Ansible · Postgres 14 on FreeBSD 13 · PostgreSQL 14 with Docker · Postgres 14 on Rocky Linux/CentOS 8 · Postgres 14 on Ubuntu 20.04 · Postgres 14 on Fedora 34 · Postgres 14 on OpenSUSE Leap 15.3
Table of contents
- Update the system
- Set up the pgAdmin repository
- Install pgAdmin 4
- Configure pgAdmin 4 web mode
- Access pgAdmin 4 and add a server
1. Update the system
Update package lists and upgrade:
| |
2. Set up the pgAdmin repository
pgAdmin 4 is not in the default Ubuntu repos. Add the official repository:
| |
Note: apt-key add is deprecated. For newer Ubuntu versions, consider using signed-by in the sources.list entry instead. The pgAdmin repository setup script may be updated in the future.
3. Install pgAdmin 4
Choose one:
- Web mode only (recommended for servers):
pgadmin4-web - Desktop mode only:
pgadmin4-desktop - Both:
pgadmin4
For a server, install web mode:
| |
4. Configure pgAdmin 4 web mode
Run the setup script to create an admin user and configure Apache:
| |
You’ll be prompted for:
- Email address for the initial admin account
- Password (twice)
- Whether to configure Apache (answer y)
- Whether to restart Apache (answer y)
Example output:
| |
pgAdmin 4 is available at http://127.0.0.1/pgadmin4 or http://your-server-ip/pgadmin4.
5. Access pgAdmin 4 and add a server
- Open http://your-server-ip/pgadmin4 in a browser.
- Log in with the email and password you set during setup.
- Click Add New Server.
- On the General tab, enter a name (e.g. “Production PostgreSQL”).
- On the Connection tab, enter:
- Host name/address:
localhost(or your PostgreSQL server IP) - Port:
5432(default PostgreSQL port) - Maintenance database:
postgres(or another database) - Username: your PostgreSQL user
- Password: your PostgreSQL password
- Host name/address:
- Click Save.
The server appears under Servers in the left sidebar. Expand it to see 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 supports PostgreSQL 9.2+ and 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 web interface is served by Apache at /pgadmin4. Config files are typically in /etc/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, set up NGINX as a reverse proxy with TLS (Let’s Encrypt) and restrict access (e.g. VPN or firewall rules).
Conclusion
You installed pgAdmin 4 in web mode on Ubuntu 22.04: added the pgAdmin APT repository, installed pgadmin4-web, ran the setup script to create an admin user and configure Apache, and added a PostgreSQL server connection. The web interface is available at http://your-server-ip/pgadmin4. For PostgreSQL installation guides, see Postgres 14 on Ubuntu 22.04 or other PostgreSQL guides linked above.