Unable to Connect to GCP MySQL from Fly.io Despite Public IP and Open Access Configuration

We have migrated our MySQL database from AWS to GCP. In GCP, we have enabled Public IP and allowed access from all IP addresses. However, the database connection does not work from Fly.io, while it works perfectly from other servers, including our local machine.

This issue is frustrating as we cannot find a solution, and Fly.io does not seem to provide a way to determine the outbound IP address.

Any solutions or suggestions would be greatly appreciated!

Hi,

You are correct that by default you don’t get a static outgoing IP. IPs come and go.

You should be able to find your machine’s current one (for debugging):

fly ssh console
echo $FLY_PUBLIC_IP

For more:

However …

(a) that’s IPv6, which GCP might not let you use (many years ago when I last used GCP it wanted an IPv4 … not sure if that’s still the case?)
(b) that IP may change. Not ideal for long-term whitelisting

If you have opened your GCP up to any address (IPv6?) that probably still won’t help though, since of course that address falls within “any” address :thinking:

Solutions?

You could assign a static outgoing IP. That way you do know it. That’s a relatively new option. For more, see:

As you can see later in that thread, people have had mixed results doing that. For some people it doesn’t seem to work … however it’s not clear why not :thinking: Could be worth a try though. There is an extra cost though.

The other solution would be to use GCP’s proxy. That was built partly for a case like this, where you don’t want to open a database up to the whole world but also don’t know the IP it will be connected to from (like with Lambda). You allow the proxy access instead of allowing an IP access. That way you wouldn’t need to have or know a static IP from Fly :slight_smile:

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