How to deploy a Rails 7 app to Fly.io

In this 5-minute lesson, you'll learn how to deploy a simple Rails 7 app to Fly.io, a popular web hosting service.

Some common errors you may run into when deploying to Fly.io:

500 error on deploy



If you get a 500 error on deploy, it may be because the database did not get set up or migrated. You need these lines in your fly.toml file:
[deploy]
  release_command = './bin/rails db:prepare'

Sometimes Fly removes that command, which causes the 500 error.

Missing assets

If you find that your CSS is not loading, even though the link tags look fine, it could be because these lines are missing or incorrect in fly.toml:

[[statics]]
  guest_path = '/rails/public'
  url_prefix = '/'

It's something Fly adds to serve assets directly from its cache (which is not quite a CDN), bypassing your web server. Sometimes the guest path is set to an incorrect value.