Skip to content

Deploy to Fly.io with your agent

Put a running app online — not just static files, but a real backend (a database, an API, a Python/Node server) that anyone opens at a live URL. Fly runs your app in a container near your users and sleeps it to $0 when idle, so a low-traffic share costs pennies.

Time: ~1 min to your agent once set up. The two un-delegable bits: create a Fly account and put a card on file — Fly verifies one even for free-trial usage. You'll need: Claude Code, and an app to ship (a folder with a Dockerfile, or any common framework — fly launch detects and configures most of them). Last verified: 2026-06-07 · commands checked against Fly's own flyctl docs. [confirmed]

New to all this? Do Set up Claude Code first, then come back. Just sharing static files — no backend? Deploy a website is lighter (Netlify needs no card). Not sure your thing even needs a server? Ask your agent — if it's plain HTML/JS, use that one instead.

Before you begin

  • Claude Code running in the folder that holds your app — ~10 min once. It installs flyctl and runs every command below.
  • An app that needs a server. A Dockerfile, or a Rails/Django/Flask/Node/Phoenix/Go project fly launch recognises. Plain static files don't need Fly. [confirmed]
  • The two things only you can do: a Fly.io account and a card on file. Fly checks a card even for trial usage. [confirmed]

New to asking an agent to run setup for you? Read How to ask your agent — one screen, then come back.

The default: ask your agent

With Claude Code running in your project folder, say:

Install the Fly CLI (flyctl) if it's missing, then log me into Fly with
`fly auth login` — stop and hand me the browser step. Then run `fly launch`
to set up and deploy this app. Pick the lhr (London) region. When it asks
to tweak settings, leave the defaults. Tell me the live URL at the end.

Your agent installs flyctl, starts the login, and pauses for the one step it can't do — you approve it in the browser. Then fly launch scans your code, writes a fly.toml config, builds a container, and ships it. In a minute or two it prints a https://your-app.fly.dev URL. That's your share. [confirmed]

Swap lhr for any region code (fly platform regions lists them — iad Virginia, nrt Tokyo, syd Sydney). Pick one near your users. [confirmed]

The two steps that are yours: account + card

flyctl can't sign you up or enter a card — Fly makes you do both.

  1. Make the account. When fly auth login (or fly auth signup) runs, it opens a browser page. Continue with GitHub/Google or an email, confirm, done. The terminal flips to "logged in" on its own. ~3 min. [confirmed]
  2. Add a card. Fly requires a valid card on file to deploy — it's anti-abuse, not a charge. On signup it may pre-authorise under $5 then cancel it immediately (your bank can show the hold for up to 7 days; no money is taken). Add it from the Fly dashboard when prompted. [confirmed]

The free trial is 2 machine-hours or 7 days, whichever runs out first — enough to stand a small app up and show it. After that, usage bills to the card; a sleep-to-zero app (below) stays near $0. [confirmed]

Keep it cheap: let it sleep

Fly can stop your app when no one's using it and wake it on the next request — so an app nobody's hitting costs nothing to run. fly launch turns this on by default for new apps. To be sure, tell your agent:

In fly.toml, set auto_stop_machines = "stop", auto_start_machines = true,
and min_machines_running = 0, then run `fly deploy`.

With those, every machine stops when idle and the first visitor waits a second or two for it to wake. [confirmed] The catch: that cold-start pause, and anything in memory is lost between sleeps — fine for a demo, use a database for real state.

Secrets: keys that never touch your code

If your app needs an API key or database URL, don't bake it into the files. Tell your agent:

Set these as Fly secrets, not in the code:
ANTHROPIC_API_KEY=sk-... and DATABASE_URL=postgres://...
Then redeploy.

It runs fly secrets set NAME=value …, which stores each encrypted and restarts your machines to pick them up — no rebuild, no key in your repo. [confirmed]

Shipping a change later

Edit the code, then one sentence: "run fly deploy." Your agent rebuilds and rolls out the new version; the URL stays the same. [confirmed]

You're done when

Your agent prints a https://your-app.fly.dev URL and it opens in a browser — yours or anyone's, no login on their end. Check it any time with fly status (running, asleep, which region) or have your agent open it with fly apps open. That URL is the share — paste it in chat, an email, a doc. [confirmed]

If it doesn't work

  • command not found: fly / flyctl → the install didn't land or isn't on your PATH. Reopen the terminal, or ask your agent to reinstall for your OS (commands in Install flyctl by hand below). On macOS, brew install flyctl is the cleanest. [confirmed]
  • "You must be logged in" / Error: not logged in → auth didn't finish. Run fly auth login again and complete the browser approval. On a remote server with no browser, it prints a URL — open it on any device (your phone works). [confirmed]
  • "Payment required" / "add a payment method" → no card on file, or the trial ran out (2 machine-hours / 7 days). Add a card in the Fly dashboard. This is the un-delegable cost — your agent can't do it. [confirmed]
  • "app name … is already taken" → app names are globally unique on Fly. Tell your agent to pass a different one: fly launch --name my-unique-name-2026. [confirmed]
  • Build / Dockerfile errorfly launch couldn't build your container. Paste the full error to your agent — usually a missing dependency, a wrong start command, or the app not listening on the port Fly expects (the internal_port in fly.toml; many frameworks want 8080). [confirmed]
  • Deploys but the page is a 502 / won't load → the app started but Fly can't reach it. The port your app listens on must match internal_port in fly.toml. Tell your agent "make the app listen on the port Fly health-checks, or fix internal_port to match." [confirmed]
  • Anything else → Fly's troubleshooting deployments guide covers the common deploy failures step by step.

Prefer to do it by hand? (flyctl from the terminal)

No agent — just you and a terminal. Install flyctl, then run four commands:

=== "macOS"

```bash
brew install flyctl
```

No Homebrew? `curl -L https://fly.io/install.sh | sh` works too (follow its note about adding flyctl to your shell config). `[confirmed]`

=== "Windows"

In PowerShell:

```powershell
pwsh -Command "iwr https://fly.io/install.ps1 -useb | iex"
```

Plain `powershell` works if you don't have `pwsh`. `[confirmed]`

=== "Linux"

```bash
curl -L https://fly.io/install.sh | sh
```

Then add flyctl to your PATH as the script's output tells you. `[confirmed]`

Then, from your project folder:

  1. fly auth signup (or fly auth login) → sign up in the browser, add a card when asked.
  2. fly launch → it scans your app, writes fly.toml, and offers to tweak settings; pick your region.
  3. It builds and deploys automatically. If it doesn't, run fly deploy.
  4. fly status shows it's live; fly apps open opens the URL. [confirmed]

Watch / read

YouTube blocked transcript pulls on 2026-06-07, so these aren't line-by-line verified — but the first two are Fly's own channel on this exact task, so the steps track the commands above.

  • Fly Launch — Machines as a building block — Fly.io, 3:06. What fly launch actually does under the hood, short. Why this one: official, and the shortest real overview of the launch step.
  • Run Laravel on Fly.io with Fly Launch — Fly.io, 11:07. A full real-app fly launchfly deploy, including secrets and config. Why this one: official end-to-end, if you want to watch the whole flow once.
  • Deploy Node.js App to Fly.io — Hayk Simonyan, 4:41. Third-party, concise install → launch → deploy. Why this one: shortest non-official walkthrough; okay start if you want a different voice.

Best written walkthrough: Fly's own Launch demo / getting started — install flyctl, fly auth signup, fly launch, fly deploy, in order. The authoritative source the commands here were checked against. [confirmed]

Sources

Good to know

  • No permanent free tier — a card is required. Fly's free trial is 2 machine-hours or 7 days, whichever ends first (10 machines, 20 GB volume, ≤2 vCPU / 4 GB each); after that, usage bills to the card. Trial machines also auto-stop after 5 min idle. Re-check live at fly.io/docs/about/free-trial. [confirmed]
  • Sleep-to-zero keeps a low-traffic share near $0, but adds a cold-start pause (~a second or two) on the first request after idle, and in-memory state is lost between sleeps — use a database, not RAM, for anything you need to keep. [confirmed]
  • A *.fly.dev URL is public. Anyone with the link can open it — don't put sensitive data on a casual share, and add login if it's not for everyone. See Who can see it? and Can you trust the company?. [confirmed]