OOM killed on Fly.io: what “Out of memory: Killed process” means, and how to see it coming
When a Fly.io log shows Out of memory: Killed process 257 (node), the kernel inside your Machine ran out of memory and killed the app. Each Machine is a small VM with a fixed amount of memory, and nothing outside it gives way. Fly.io then restarts the Machine according to its restart policy, and may email you that the app ran out of memory. For the general picture, see exit code 137 and OOM killed.
Confirm it
fly logsshows the kernel’sOut of memory: Killed processline, with the process name and its memory.- In Fly.io’s metrics, the
fly_instance_exit_oomseries is 1 when a Machine was killed for exceeding its memory. - The memory panels in Fly.io’s managed Grafana show
fly_instance_memory_mem_availablefalling towards zero before the kill.
How to fix it
- Give the Machine more memory:
fly scale memory 1024. The smallest presets leave little room for Node, Python or Ruby. - Add swap with
swap_size_mbinfly.toml. It is a cushion for short peaks, not a fix for a leak. - Cap the runtime. For Node, set
--max-old-space-sizeto about 75 percent of the Machine’s memory. - Size the release command. Migrations and asset builds often need more memory than the running app, and a kill there fails the deploy. Give the release Machine more with
[deploy.release_command_vm]infly.toml. - Split process groups, so a worker that needs memory runs on its own Machine size.
What Fly.io warns you about
Fly.io may email you after an OOM kill. It has no built-in alerting on metrics, and its managed Grafana has no alerting either. To be warned while memory is climbing, you have to run your own Grafana or Prometheus alerting against Fly.io’s metrics.