sailfork / t3code-github / .repos/ alchemy-effect/ website/ src/ content/ docs/ fly/ compute/ regions.mdx

A region is a Fly.io datacenter. Machines, Volumes, Postgres clusters, and a Redis primary live in one. An App is global. It is not pinned to a region.

Alchemy defaults to iad (Ashburn, Virginia). Pass region to put a Service, Machine, or Postgres cluster somewhere else.

Pin a Service

export default class Api extends Fly.Service<Api>()(
  "Api",
  { main: import.meta.url, region: "lhr", port: 3000 },
  Effect.gen(function* () {
    return {
      fetch: Effect.succeed(HttpServerResponse.text("hello")),
    };
  }),
) {}

count Machines run in that region.

:::caution[Changing region moves the Machines] The Service keeps its App and hostname. Machines are created in the new region and the old ones are deleted. A Volume does not move with them. :::

Pin a Machine

const web = yield* Fly.Machine("Web", {
  app: Site,
  region: "syd",
  image: "nginx:alpine",
});

Each Machine resource is one VM in one region. To run in two regions, declare two Machines.

:::caution[Changing region replaces the Machine] The Machine is created in the new region. The old one is deleted. :::

Volumes stay in the region

A Volume is created in the parent Service or Machine's region. It cannot move and cannot attach to a Machine in another region.

Restore into a new region from a VolumeSnapshot with snapshotId on the mount.

Several regions, one hostname

Pass a list to region to run the same Service in several regions behind one hostname. count Machines run in each region, and Fly's Anycast proxy sends each request to the nearest healthy Machine.

export default class Api extends Fly.Service<Api>()(
  "Api",
  { main: import.meta.url, region: ["iad", "lhr"], count: 2 },
  Effect.gen(function* () {
    return {
      fetch: Effect.succeed(HttpServerResponse.text("hello")),
    };
  }),
) {}

This runs four Machines: two in iad and two in lhr. api.regions is ["iad", "lhr"], and api.url serves from both.

Adding or removing a region updates the Service in place. Its App and hostname stay the same, Machines in regions you keep are left alone, and a removed region's Machines are deleted. A Volume from MountVolume is created in each Machine's own region.

Which region is this?

Fly sets FLY_REGION on the Machine. Read it in a Service with Config.

import * as Config from "effect/Config";

const region = yield* Config.String("FLY_REGION");

Region codes

Codes are three letters. This list is what Fly published as of August 2026. Run fly platform regions or see Fly's regions for the live set.

CodeLocation
amsAmsterdam, Netherlands
arnStockholm, Sweden
bomMumbai, India
cdgParis, France
dfwDallas, Texas (US)
ewrSecaucus, NJ (US)
fraFrankfurt, Germany
gruSão Paulo, Brazil
iadAshburn, Virginia (US)
jnbJohannesburg, South Africa
laxLos Angeles, California (US)
lhrLondon, United Kingdom
nrtTokyo, Japan
ordChicago, Illinois (US)
sinSingapore
sjcSan Jose, California (US)
sydSydney, Australia
yyzToronto, Canada

A dedicated IpAssignment can take region too. Shared Anycast (shared_v4) ignores it.

Postgres is regional

The cluster lives in one region. Pass region on Fly.Postgres, not on the App.

const db = yield* Fly.Postgres("Db", {
  region: "iad",
});

:::caution[Changing region replaces the cluster] A new cluster is created in the new region. The old cluster is deleted. Data is not copied. :::

Redis primary

Fly.Redis takes primaryRegion. Default is iad. Read replicas are extra regions on readRegions.

const cache = yield* Fly.Redis("Cache", {
  primaryRegion: "iad",
  readRegions: ["sjc"],
});

:::caution[Changing primaryRegion replaces Redis] The primary region is immutable. The old database is deleted first. :::

Where next

Services pin region on the class. Machines pin it on the resource. Volumes follow the parent. Postgres is a billed cluster in one region. Redis pins primaryRegion.