Recently, I ran into a small but confusing problem while connecting TablePlus to a DigitalOcean Managed Database.
At first, I thought something was wrong with TablePlus.
It wasn’t.
The real problem was my public IP address.
Here’s what happened.
The Problem
I created a managed database on DigitalOcean and wanted to connect to it from my laptop using TablePlus.
DigitalOcean has a Trusted Sources option where you need to allow the IP addresses that can connect to your database.
So I searched:
What is my IP?
I copied the IP, added it to DigitalOcean, and tried to connect.
But things were not working as expected.
Then I decided to check my public IP from the terminal.
I ran:
curl api.ipify.org
and also:
curl ifconfig.me
That made things even more confusing.
The output looked messy because the IP appeared together with some curl progress information.
For a moment, I wasn’t even sure which number was my actual IP.
First, I Cleaned Up the Command
Instead of using plain curl, I used:
curl -4 -sS https://ifconfig.me/ip && echo
Now the output was simple:
203.0.113.10
Much better.
The -4 makes sure I get an IPv4 address, and -sS removes the unnecessary progress output.
But then I noticed something strange.
A little later, I checked again and got something like:
203.0.113.14
My public IP had changed.
That was the actual problem.
Why Was My IP Changing?
My internet connection was using a dynamic public IP.
Depending on your ISP, this can also happen when you are behind something like CGNAT.
So even though I was using the same laptop and the same internet connection, the public IP seen by DigitalOcean could change.
For example:
203.0.113.10
might later become:
203.0.113.14
If DigitalOcean only trusts the first IP, TablePlus will stop connecting after the IP changes.
That explained why the connection sometimes worked and sometimes didn’t.
How I Solved It
In my case, I needed to make sure DigitalOcean trusted the correct source address.
For temporary development, the simplest solution is to check your current IP:
curl -4 -sS https://ifconfig.me/ip && echo
Then add that IP to:
DigitalOcean
→ Database
→ Network Access
→ Trusted Sources
After updating the trusted IP, I tried TablePlus again.
And this time:
Connected.
The database loaded normally.
What About Using /24?
While debugging this, I also learned about CIDR ranges such as:
203.0.113.0/24
A /24 allows the whole range from:
203.0.113.0
to:
203.0.113.255
This can be useful if you know your traffic can come from that whole range.
But there is an important catch.
If you see:
203.0.113.10
and later:
203.0.113.14
you should not automatically assume that you should allow:
203.0.113.0/24
That would allow many more IP addresses than just yours.
For local development, I prefer allowing my current IP unless I know exactly which CIDR range I should trust.
If your IP changes very often, a static IP, VPN with a fixed exit IP, or another stable connection can be a cleaner long-term solution.
What I Learned
The funny thing is, I started debugging this as a TablePlus issue.
Then I thought it was a DigitalOcean issue.
But in the end, it was mostly a networking issue.
If you ever face the same problem, check your public IP first:
curl -4 -sS https://ifconfig.me/ip && echo
Then compare it with the IP in your DigitalOcean Trusted Sources.
Sometimes a database connection problem has nothing to do with the database at all.
And that was the small networking lesson I learned while trying to connect TablePlus to DigitalOcean.
Top comments (0)