Deploy pgAdmin 4 on Ubuntu with Docker — the most popular open-source PostgreSQL management and administration platform with a rich web interface for query execution, schema browsing, and server monitoring.
Grab the automated bash script from GitHub to follow along with the video.
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/databases/pgadmin/pgadmin-ubuntu.sh
chmod +x pgadmin-ubuntu.sh
sudo bash pgadmin-ubuntu.sh
The script installs Docker, starts pgAdmin 4, and generates login credentials automatically. The credentials are displayed at the end of the script.
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/databases/pgadmin/pgadmin-ubuntu.sh
chmod +x pgadmin-ubuntu.sh
sudo bash pgadmin-ubuntu.sh
Open your browser and navigate to pgAdmin. Login with the auto-generated credentials shown in the script output:
http://<your-server-ip>:5050
Right-click 'Servers' in the left object browser → Register → Server. Enter a name in the General tab. Switch to the Connection tab and fill in: Host (PostgreSQL server IP or container name), Port (5432), Username, and Password. Click Save to connect.
Browse schemas, tables, indexes, and constraints in the object browser tree. Right-click any table for quick options. Use Tools → Query Tool to open a SQL editor, write queries, run them with F5, and view results. Save frequently-used queries to files for later use.
| Port | Purpose |
|---|---|
| 5050 | pgAdmin 4 Web UI |
pgAdmin 4 is the leading open-source management and administration tool for PostgreSQL. Unlike generic database management tools, pgAdmin is purpose-built for PostgreSQL's specific features — it exposes advanced capabilities like query plan visualization with EXPLAIN ANALYZE, tablespace management, replication monitoring, extension management, and server activity dashboards that generic tools cannot match. Deployed as a web application, it runs in Docker and is accessible from any browser without per-machine installation.
pgAdmin 4 gives PostgreSQL users a fully featured visual interface for database operations that would otherwise require complex command-line knowledge. The Query Tool's graphical query plan viewer transforms EXPLAIN ANALYZE output into readable diagrams, making performance tuning accessible to developers who are not PostgreSQL experts. For teams managing multiple PostgreSQL servers across development, staging, and production, pgAdmin's server group organization and saved connections eliminate the need to remember and retype connection details.
pgAdmin 4 listens on port 5050 by default (HTTP). This port should never be publicly accessible without HTTPS and authentication. Place pgAdmin behind Nginx Proxy Manager on port 443 with a valid SSL certificate. In UFW: block port 5050 from external access (ufw deny 5050) and allow it only from your LAN or VPN subnet. For remote developer access, route through a VPN or SSH tunnel: ssh -L 5050:localhost:5050 user@server, then open localhost:5050 in your local browser.
Adminer is a lighter alternative that supports multiple database engines including PostgreSQL — ideal when you need a simpler, faster interface without pgAdmin's full feature set. DBeaver is a cross-platform desktop client with excellent PostgreSQL support and ERD generation — better for developers who prefer a native app. TablePlus and DataGrip are polished commercial alternatives. psql (the official PostgreSQL CLI) is always available for scripting and automation. For teams using PostgreSQL exclusively and needing deep feature access including query plan analysis and server monitoring, pgAdmin 4 remains the most capable free option.
Don't use pgAdmin if you need multi-database-engine support — use Adminer or DBeaver instead. For purely programmatic database administration in CI/CD pipelines, psql and pg_dump with shell scripts are more appropriate than a GUI. pgAdmin is heavyweight for very simple use cases like checking a single table — a quick psql connection is faster. If your team primarily uses ORMs and never writes raw SQL, the operational complexity of maintaining pgAdmin may not justify the value compared to a simple Adminer instance.
PrismaTechWork provides end-to-end infrastructure services — from initial deployment and security hardening to ongoing monitoring, automated backups, and dedicated support. Whether you need a single-server setup or a multi-site network, our team ensures your infrastructure is built right, secured properly, and maintained reliably.
pgAdmin 4 is the current major release — a complete rewrite in Python and JavaScript with a modern web-based interface. pgAdmin 3 was a legacy desktop application that is discontinued. pgAdmin 4 runs as a web server accessible from any browser and can be deployed in Docker, eliminating per-machine installation.
Yes. Register any number of PostgreSQL connections by right-clicking Servers → Register → Server. Organize them into server groups for dev, staging, and production. Switch between servers instantly. All connections are saved in the pgAdmin configuration database inside the Docker volume.
Open the Query Tool from the Tools menu or right-click a database → Query Tool. Type SQL in the editor, press F5 to execute, view results in the Data Output panel. Features include syntax highlighting, autocomplete, query history, and the Explain button for graphical query plan visualization.
Yes. pgAdmin 4 is completely free and open-source under the PostgreSQL License. There are no paid tiers, no feature restrictions, and no account requirements. It is maintained by the pgAdmin Development Team and the PostgreSQL Global Development Group.
Place pgAdmin behind Nginx Proxy Manager with HTTPS. Restrict port 5050 to localhost via firewall. Enable 2FA under File → Preferences → Security. Use a strong pgAdmin login password. Consider VPN-only access to fully prevent public exposure.
Yes. Enter the remote server IP or hostname in the Connection tab when registering a server. The remote PostgreSQL must allow connections from pgAdmin's IP in pg_hba.conf and listen_addresses. For encrypted connections, enable SSL in the Connection tab. Use SSH tunneling for maximum security.
The master password encrypts saved server credentials (passwords) stored in the pgAdmin configuration database. It is different from your pgAdmin login password. Set a strong master password on first login. If forgotten, it can be reset from the login screen but all saved server passwords will be lost.
Right-click a database → Backup. Choose Custom format (compressed, restorable with pg_restore), set the file path, and click Backup. pgAdmin calls pg_dump internally. For large databases, pg_dump from the command line is faster. To restore, right-click a database → Restore and select your backup file.