DEV Community

Hrishi Mittal
Hrishi Mittal

Posted on • Originally published at learnetto.com

How to deploy a Rails 7 app to Fly.io

This is a video lesson from the Full Stack Rails Mastery course.

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

Image description

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'

Enter fullscreen mode Exit fullscreen mode

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 = '/'
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)