PostgreSQL is a powerful, open-source object-relational database system known for its reliability, feature robustness, and performance. When you deploy a database-ready VPS with HostGraber, we often pre-configure your environment to save you time.

This guide will walk you through verifying that your PostgreSQL service is installed, active, and ready for your applications.


1. Access Your Server and Retrieve Credentials

To begin, log in to your server via SSH using your server IP and the root credentials provided in your HostGraber Welcome Email.

Once logged in, you need to retrieve your specific database details stored on your server.

Run the following command:

 
cat /root/credential.txt

This will display your Database Name, Username, and Passwords. Keep these handy for the steps below.


2. Check the Service Status

First, ensure the PostgreSQL service is actually running in the background.

Command:

 
systemctl status postgresql
  • What to look for: You should see Active: active (exited) or active (running). If it says inactive or failed, you may need to start it using sudo systemctl start postgresql.


3. Verify the Network Port

PostgreSQL typically listens on Port 5432. You can check if the server is "listening" for incoming connections.

Command:

 
ss -tulnp | grep 5432
  • Expected Output: You should see a line showing LISTEN on 0.0.0.0:5432 or 127.0.0.1:5432.


4. Test the Database Connection

The most reliable way to check the installation is to log into the PostgreSQL prompt. Since the root user does not exist in PostgreSQL by default, you should use the postgres system user.

Method A: Enter the Interactive Console

 
sudo -i -u postgres psql

Once inside, you can run \conninfo to see connection details or \q to exit.

Method B: List All Databases (One-liner)

To verify that your specific database (found in your credential.txt) exists:

 
sudo -u postgres psql -l

This command lists all databases currently managed by the server.


5. Locate Important Configuration Files

If you need to tweak performance or allow remote connections, you need to know where your config files live. You can find them directly via the SQL interface:

  • Config File: sudo -u postgres psql -c "SHOW config_file;"

  • Data Directory: sudo -u postgres psql -c "SHOW data_directory;"

  • HBA (Permissions) File: sudo -u postgres psql -c "SHOW hba_file;"


Troubleshooting Tips

  • Role "root" does not exist: This is normal. PostgreSQL uses "roles." Always access the initial setup via the postgres user or the specific custom user provided in your credential.txt.

  • Connection Refused: Ensure your firewall (like UFW) allows port 5432 if you are trying to connect from an external application.

For further assistance with your database hosting, visit our support portal at HostGraber.com.


Summary Checklist

Task Command
Check Version psql --version
Check Status systemctl status postgresql
View Credentials cat /root/credential.txt
Access Console sudo -u postgres psql

 

Need more power for your database? Check out our high-performance VPS plans.

Was this answer helpful? 0 Users Found This Useful (0 Votes)