Deploy a Claude Code app to Fly.io

For Dockerised apps that need to run close to users. No free tier.

Specific to Claude Code + Fly.io
  • Ask Claude Code to write a Dockerfile, then run fly launch from the project folder.

Step by step

  1. Check your project type

    • Static / SPA: Build outputs dist/, build/ or out/.
    • Server app / API / bot: Has a start command that keeps running, often a Dockerfile.
  2. Get the code onto GitHub

    • Ask it to initialise git and create a GitHub repo, or run git init / git push yourself.
  3. Create the project on Fly.io

    Install flyctl, run fly launch in the project folder (it detects a Dockerfile or framework), then fly deploy for later updates.

  4. Check the build settings

    A Vite SPA is typically built in a Docker stage and served by nginx on port 80 (set internal_port in fly.toml).

    For Claude Code: build command From package.json / Dockerfile, output Depends on framework.

  5. Add environment variables before the first build

    In Fly.io: fly secrets set NAME=value for runtime secrets; build-time VITE_* values must be passed as build args. Copy these from Claude Code:

    • Everything in .env — add each value in the host dashboard.

    Changed a value later? Rebuild. Vite bakes variables in at build time. Troubleshoot missing env vars

  6. Make page refreshes work (Vite / React Router single-page apps served by nginx)

    nginx.conf
    location / {
        try_files $uri $uri/ /index.html;
    }

    Server-rendered projects (TanStack Start, Next.js) don't need this. Fly.io docs (opens in a new tab)

  7. Update login redirect URLs

    Add your new Fly.io URL (and later your custom domain) to your auth provider's allowed URLs. Redirect troubleshooting

  8. Add your domain

    fly certs add yourdomain.com, then create the A/AAAA (or CNAME) records flyctl prints.

What it will cost

Trial only No free tier — free trial of 2 VM hours or 7 days, whichever comes first. Paid from ≈$2.19/mo: Pay-as-you-go: shared-cpu-1x · 256 MB is $2.19/month in Ashburn (iad); region multipliers apply. Managed Postgres from $38/month. Checked 17 Oct 2026 on Fly.io's pricing page (opens in a new tab).

  • Needs the flyctl CLI and usually a Dockerfile — not the lowest-friction choice for non-developers.

Other options for Claude Code