Fly.io apps are often configured to share IP addresses by default, but for certain use cases, you’ll need a dedicated IPv4 address.
Let’s see it in action. Imagine you have a simple web app deployed to Fly.io. By default, it might be served from a shared IP address.
# Initially, no dedicated IP is assigned
flyctl ips list --app my-awesome-app
# Output: No dedicated IPv4 addresses found for my-awesome-app.
Now, let’s allocate a dedicated IPv4 address.
flyctl ips allocate-v4 --app my-awesome-app
# Output: Allocated new IPv4 address: 172.104.168.134
After this, flyctl ips list will show your dedicated IP.
flyctl ips list --app my-awesome-app
# Output:
# TYPE ADDRESS CREATED
# v4 172.104.168.134 2023-10-27T10:00:00Z
# shared fdaa:0:1234:1::1
This dedicated IP is now the primary way your application will be accessible from the internet, bypassing the shared IP pool.
The core problem this solves is the need for a stable, predictable, and directly routable IP address for your application. Shared IPs, while efficient for scaling and cost, can have downsides:
- DNS TTLs: If your DNS records point to a shared IP that changes, you can experience downtime or slow propagation during updates. A dedicated IP means your DNS records remain valid.
- External Firewalls/Allow-listing: Many services require you to explicitly allow specific IP addresses. With a shared IP, this is impossible as the IP can be used by many other applications.
- TLS Certificates (older methods): While Fly.io handles certificates automatically with its shared IPs, some legacy systems or specific configurations might require you to bind certificates to a dedicated IP.
- Port Conflicts (rare on Fly.io, but conceptually): In very high-traffic scenarios or with specific network configurations, relying solely on shared IPs might, in theory, lead to issues if not managed perfectly by the platform. A dedicated IP gives you a direct line.
Internally, when you allocate a dedicated IPv4, Fly.io provisions a unique public IPv4 address and associates it directly with your application’s virtual machine instances. This IP is then advertised to the internet and routed to your app’s egress. The platform ensures that traffic hitting this IP is directed to one of your running instances. When you scale your app up or down, Fly.io manages the load balancing behind this single dedicated IP.
The primary lever you control is the flyctl ips allocate-v4 command. Once allocated, the IP is yours for the life of the application or until you explicitly release it. You can also detach and reattach a dedicated IP to a different app within your account using flyctl ips detach-v4 and flyctl ips attach-v4.
It’s important to understand that a dedicated IPv4 address is a resource that incurs a small monthly cost. This cost covers the rental of the IP address from the IP address provider. Fly.io passes this cost on.
When you release a dedicated IPv4 address using flyctl ips release-v4 --app my-awesome-app --ip 172.104.168.134, Fly.io decommissions that specific IP from your account. The IP address itself is returned to the pool of available IPs and may be reassigned to another customer in the future. Your application will then revert to using shared IPv4 addresses for egress, if any are available, or solely rely on IPv6.
The next thing you’ll likely encounter is managing IPv6 addresses for your applications.