Machine cannot find external IP (the database IP)

I just deployed a new app, a simple web app that uses $DATABASE_URL to connect to PostgreSQL.

However, the app fails to start up. In my debug process I found that the web server does not start because it cannot connect to the database (which is not hosted by Fly).

  • Using the same credentials I can connect to that database from
    • my personal computer
    • a Paas similar to Fly
  • The database server has no restriction based on the incoming IP address
  • I apt installed psql and ping in my Fly machine (via fly ssh console) and it looks like it cannot “see” the PostgreSQL’s server IP address:
    • psql hangs indefinitely (no error)
    • ping -c 4 to the IP gives 4 packets transmitted, 0 received, 100% packet loss, time 3054ms
  • The URI credentials uses IPv4 (not sure if relevant), like postgres://user:passwor@XXX.XXX.XXX.XXX/name
  • nc -n -vz <IP ADDRESS> hangs without an error

Any ideas about what can be going on or ideas to try?

Thank you

Hi… I would try those same tests (ping, psql, nc) from a Fly.io machine created in a widely separated region (e.g., in nrt if you’re currently in the Americas).

You may have ended up with an egress IP that has a bad reputation with that particular database service.

Hope this helps a little!

1 Like

Added machines, postgres

So weird! But it worked :sparkles:
Thank you so much.

For those interested: the PostgreSQL server is in Nuremberg :de: and I was using Fly’s Frankfurt :de: region.

I switched to Amsteram :netherlands: and it worked like a charm!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.