Post

Can’t Connect to Your PostgreSQL Database on DigitalOcean? Here’s the Fix!

Can’t Connect to Your PostgreSQL Database on DigitalOcean? Here’s the Fix!

The Problem

You’ve set up a PostgreSQL database on DigitalOcean, but when you try to connect, nothing happens — no error, no timeout, just an unresponsive connection.

The Fix: Add Your IP to Trusted Sources

DigitalOcean restricts access to your database by default. To connect from an external machine, you need to add your IP to the trusted sources.

Steps to Fix It

  1. Go to DigitalOcean Cloud Console and navigate to your PostgreSQL database.
  2. Under the Troubleshooting tab, find the option to add your current IP.
  3. Click the button to add your IP and save the changes.
  4. Reconnect using your PostgreSQL client or terminal:
1
psql -h your-database-host -U your-user -d your-database-name -p 25060

This should instantly resolve the issue, allowing you to connect without delays. Just make sure your version of psql is the same with that of the Digital Ocean database.

Conclusion

By adding your IP in the Troubleshooting tab, you ensure secure and immediate access to your PostgreSQL database. A quick fix that saves time and frustration!

This post is licensed under CC BY-NC 4.0 by the author.