๐Ÿ˜ How to Install pgAdmin 4 Web on a Remote Ubuntu Server via SSH (With Full Error Fixes)

๐Ÿ˜ How to Install pgAdmin 4 Web on a Remote Ubuntu Server via SSH (With Full Error Fixes)

Managing PostgreSQL via the command line is powerful — but sometimes, you need a graphical interface. pgAdmin 4 in web mode is a top-tier choice for PostgreSQL management. In this guide, you'll learn how to install pgAdmin 4 on a remote Ubuntu server via SSH, and fix every common error along the way.

๐ŸŽฏ By the end, you’ll have pgAdmin 4 running in your browser, ready to manage any PostgreSQL server — local or remote.


๐Ÿงฐ Prerequisites

Make sure you have:

  • โœ… Ubuntu 20.04 or later on your server

  • โœ… SSH access (user or root)

  • โœ… PostgreSQL already installed (optional, but recommended)


๐Ÿ“ฅ Step 1: SSH Into Your Server

First, connect to your Ubuntu server:

ssh your-user@your-server-ip

Example using a username:

ssh devlop@103.206.13.xxx


๐Ÿ”„ Step 2: Update Packages and Install Dependencies

Update your package list and install essential dependencies, including Apache (required for pgAdmin web mode):

sudo apt update && sudo apt upgrade -y
sudo apt install curl ca-certificates gnupg apache2 -y

Make sure Apache is installed before you install pgAdmin.


๐Ÿ“ฆ Step 3: Add the pgAdmin Repository

Add the official pgAdmin APT repository securely using GPG:

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

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

sudo apt update


๐Ÿงฑ Step 4: Install pgAdmin 4 Web Mode

Now install the web version of pgAdmin 4:

sudo apt install pgadmin4-web -y


โš™๏ธ Step 5: Run the Setup Script

Initialize pgAdmin:

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

You should see:

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

If you don’t see this, no worries — a fix is below.

Say yes (y) to restarting Apache when prompted.


๐Ÿž Common Errors & Fixes

โŒ Didn’t Get Prompted for Email/Password?

This means pgAdmin was already initialized without a user.

โœ… Fix it:

sudo rm -rf /var/lib/pgadmin
sudo /usr/pgadmin4/bin/setup-web.sh

You’ll now be prompted to set the email and password.


โŒ Apache Fails to Start?

Check Apache status:

sudo systemctl status apache2

If you see:

apache2: Could not open configuration file /etc/apache2/apache2.conf: No such file or directory

โœ… Fix it by reinstalling Apache:

sudo apt purge apache2 apache2-utils apache2-bin apache2.2-common -y
sudo rm -rf /etc/apache2
sudo apt install apache2 -y

Then rerun the setup:

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


โŒ Port 80 Already in Use?

Check what’s using port 80:

sudo lsof -i :80

If it's another service (like nginx or tor):

โœ… Stop it:

sudo systemctl stop nginx

Then restart Apache:

sudo systemctl restart apache2


๐ŸŒ Step 6: Access pgAdmin in Your Browser

Now head to your browser and go to:

http://your-server-ip/pgadmin4

Or, for local access:

http://103.206.13.xxx/pgadmin4

Log in using the email and password you set earlier.


๐Ÿ—„๏ธ Step 7: Connect to Your PostgreSQL Server

Once logged in:

  1. Click “Add New Server”

  2. Go to the Connection tab and enter:

  3. Save the server, and you're in!

 

Field Value
Hostname/address localhost (or your server IP address)
Port 5432 (default for PostgreSQL)
Maintenance DB postgres
Username postgres or the DB user you created
Password Your PostgreSQL password

 




๐Ÿงฉ Step-by-Step: Register a New Server in pgAdmin

๐Ÿ“ 1. Open pgAdmin

๐Ÿ“Œ 2. Click "Add New Server"

  • On the pgAdmin welcome dashboard, find "Quick Links" → "Add New Server"

  • Alternatively, right-click on "Servers" in the Object Explorer panel (left sidebar), then click "Create → Server..."


๐Ÿ“ 3. In the "Create - Server" Dialog

๐Ÿ”ธ General Tab

  • Name: Give any name (e.g., Chatbot DB, Local PostgreSQL, etc.)


๐Ÿ”ธ Connection Tab

Here’s where you enter your actual database details:

Field Value
Host name/address localhost (if pgAdmin is on the same machine as PostgreSQL) or use 127.0.0.1 or server IP
Port 5432 (default PostgreSQL port)
Maintenance database chatbot
Username bol7user
Password Your password (e.g., bol3452&^$&(124))
Save Password? โœ… Check this for convenience

 


โš™๏ธ 4. Advanced (Optional)

If you want to customize the connection timeout or SSL settings, use the Advanced or SSL tabs.


๐Ÿ’พ 5. Save and Connect

  • Click the Save button.

  • pgAdmin will now attempt to connect to the PostgreSQL server using the credentials you provided.

  • If successful, you’ll see the new server listed under Servers on the left panel, with expandable objects like databases, schemas, tables, etc.


โœ… Final Test

After successful connection:

  1. Expand:

    • Servers → [Your Server] → Databases → chatbot → Schemas → public → Tables

  2. Right-click Tables → View/Edit Data → All Rows to browse content.

  3. Or go to Tools → Query Tool and run:

SELECT * FROM users;


๐Ÿ› ๏ธ Troubleshooting

Issue Fix
โŒ "Connection refused" Make sure PostgreSQL is running, and that port 5432 is open
โŒ "Password authentication failed" Double-check the bol7user credentials
โŒ "No such table" Ensure you're connecting to the correct database (chatbot)

โœ… Final Summary

By now, you’ve successfully:

  • Installed pgAdmin 4 Web Mode on Ubuntu

  • Handled all common Apache and pgAdmin setup issues

  • Connected to your PostgreSQL server via GUI

pgAdmin 4 is now running on your server, available in any browser — and ready to manage all your databases.


๐Ÿ’ฌ Questions? Comments? Let me know below or reach out — happy to help troubleshoot!

1 Comments

Vicky Kumar

If you forget passowrd, you can reset using: ALTER USER youruser WITH PASSWORD 'NewSecurePasswordHere';

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading...