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.

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

ITRS image

See What Users Experience in The Browser — Anywhere, Anytime

Simulate logins, checkouts, and payments on SaaS, APIs, and internal apps. Catch issues early, baseline web performance, and stay ahead of incidents. Easily record user journeys right from your browser.

Start Free Trial