How Fly.io anycast picks the nearest healthy Machine
By Christophe Paka · Facts checked on 7 November 2026
Your app runs in Ashburn and Amsterdam. A reader asks what many people ask: "if the user is in Tokyo, how would the browser know which instance to route the request to?" You have one address and nothing to set up.
Without the picture, it is easy to add an address per region, or to miss why one sick Machine never took the app down.
This figure reduces fly.io anycast to its two parts: the network picks the nearest edge, and the proxy picks the nearest healthy Machine.

Use this diagram on your site
Free to share in your blog post, docs, course or slides, as long as the credit link stays. Paste the code below where the figure should go.
How to read this figure
Start with the client at the bottom. A client anywhere dials one address. It never picks a datacenter. Your app gets this one public address, and adding regions never changes it.
The anycast box: one address everywhere. Anycast is one address that every Fly city answers. Picture a chain of shops with one phone number: the phone network rings the closest branch. Here the internet's own routes send each user to the nearest Fly edge. Nearest means the shortest path across the network, which is not always the closest city on a map. Fly runs it, and you never set it up.
Left arrow: the nearest healthy datacenter. At the edge, the Fly Proxy hands the request to the nearest healthy Machine. Healthy means it passes its health check, an automatic test request that asks your app if it works. Here the nearest datacenter is healthy, so it answers.
Dashed arrow: the sick one is skipped. The box on the right is near but fails its health check, so the proxy skips it. The proxy notices a failure within one check. Crystal Notes, the book's sample app, runs its check every 30 seconds, a number you set yourself. Once the proxy knows, the client never sees the sick Machine.
Middle arrow: the fallback. Another datacenter, healthy but further away, takes the request. Fly calls this a hairpin: in at one edge, answered in another region. Adding regions has a trap of its own, shown in the distributed app trap.
Key takeaways
- Keep one public address and add regions instead of addresses; anycast and the proxy route each request.
- Give every app a health check, because a Machine that fails it gets no visitors.
- Run a Machine in a second region, so a failed one has somewhere to hairpin to.
Worked example: one app in Ashburn and Amsterdam
Crystal Notes runs two Machines behind one address: one in iad (Ashburn) and one in ams (Amsterdam).
- A reader in Lisbon opens the app. The request reaches a European edge, and the proxy sends it to the ams Machine.
- A reader in Ohio opens the same address. The request reaches a North American edge and the iad Machine.
- The ams Machine fails its health check. The proxy sees it within one check, 30 seconds at most.
- The next Lisbon request hairpins across the Atlantic to iad. It is slower, but it is answered.
Result: Two regions, one address, and no change for the reader. The failure case is the app itself: if it listens only on 127.0.0.1, no Machine is ever healthy and nothing answers anywhere.
Questions readers ask
Do I need one IP address per region on Fly.io?
No. Your app gets one public address, announced from every Fly city. Adding a region adds a place to send requests, and the address never changes. The network picks the nearest edge, and the proxy picks the nearest healthy Machine.
How fast does Fly.io notice an unhealthy Machine?
The proxy learns it from the health check, which runs as often as you set it to. Crystal Notes runs its check every 30 seconds, so the proxy sees a failure within one check, 30 seconds at most. Until the Machine passes again, requests go to the next healthy one.
Why does my Fly.io app answer in no region at all?
Usually the app listens on 127.0.0.1, an address that takes connections from inside the Machine alone. Then no Machine is ever healthy, so the proxy has nowhere to send requests. Make the app listen on 0.0.0.0 at the internal port, then deploy again.
Sources: Fly.io networking: services (Fly.io docs); Deploy an app (Fly.io docs).
This figure is from Fly.io Made Crystal Clear, chapter 2.
The chapter builds the idea step by step, with recipes you can follow, a Try it to check yourself, and every source.
Get the book


