Opyntel

Why a Fly.io Machine keeps restarting, and how to hear about it

A Fly.io Machine keeps restarting because its main process exits and the restart policy starts it again. Machines from fly launch or fly deploy use the on-failure policy. It retries up to 10 times in five minutes, then leaves the Machine stopped. fly machine status lists the Machine’s recent events with their exit codes. For the general picture, see why a container keeps restarting.

Confirm it

bash
fly machine list
fly machine status <machine-id>
fly logs --machine <machine-id>

The status shows each exit with its code. An out-of-memory kill also shows as Out of memory: Killed process in the logs; see OOM killed on Fly.io.

Fly.io restart policies

  • on-failure restarts after a non-zero exit, up to 10 times by default. It is the default for Machines from fly launch and fly deploy.
  • always restarts after any exit, including a clean one.
  • never leaves a stopped Machine stopped.

Set the policy and the number of retries in fly.toml under [[restart]], with policy and retries. The CLI spells the same policies on-fail, always and no in fly machine update --restart.

How to fix it

  • Out of memory: give the Machine more memory with fly scale memory 1024.
  • A crash on boot: check the secrets with fly secrets list, and the start command in the Dockerfile or fly.toml.
  • A process that finishes: keep the server in the foreground, or use the never policy for a task.

What Fly.io tells you

Apart from an email when a Machine runs out of memory, Fly.io sends nothing when a Machine restarts, or when it stops after its last retry. The metrics in Fly.io’s managed Grafana have no alerts until you build them, and restart events live per Machine, in the CLI or the Machines API.

How Opyntel catches it

Opyntel reads Machine events through the Fly.io Machines API, so restarts, exit codes and out-of-memory kills land on one activity timeline for every app. A Machine that restarts more often than your threshold, or is left stopped after its retries, sends an alert by email, Slack or SMS depending on your plan.

FAQ

Fly.io restart questions, answered

Restart limits, stopped Machines and alerts.

With on-failure, up to 10 times in five minutes by default. You can change it with retries in fly.toml.

Fly.io leaves it stopped. Fix the cause, then start it again with fly machine start or a fresh deploy.

No, apart from an email on an out-of-memory kill. Opyntel alerts when restarts pass your threshold, across every app.

The alerts your platform doesn’t send.

One dashboard for everything you run, with the alerts your platforms leave out. Read-only, nothing to install in your apps.

See how it works