DEV Community

Cover image for Deploying a Rails App with Kamal on Hetzner: A Beginner's Guide

Deploying a Rails App with Kamal on Hetzner: A Beginner's Guide

Adrien Poly on June 09, 2023

Hello there! I was curious about Kamal and wanted to give it a try to host a simple application on a cheap VPS. With this guide, I'll walk you thr...
Collapse
 
samuelodan profile image
Samuel O'Daniels

Wow! It's that simple? I heard DHH talk about it a while ago (if I remember correctly) and thought to myself, "this has to be pretty complicated."

I currently use Dokku + Digital Ocean and I'm happy with it, but I'd like to try this one out.
Thanks for making this post.

Collapse
 
lucasayb profile image
Lucas Yamamoto

Really nice. Never heard of MRSK before! Thanks for the article!

Collapse
 
raynawara profile image
Raymond J Nawara

No matter how many times I try, I can never get this to run.

Do I need a SSL Certificate? I always get:

`This site can’t be reached5.78.92.233 refused to connect.
Try:

Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED`

I can connect to the server and docker ps shows everything up:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c2e4f9fedad8 rjnawara/my-hertzner-app:f6fe46ed0ee6583762587f8038152fa2ebf728e7 "/rails/bin/docker-e…" 4 minutes ago Up 4 minutes (healthy) 3000/tcp my-hertzner-app-web-f6fe46ed0ee6583762587f8038152fa2ebf728e7
74a3188bb817 traefik:v2.9 "/entrypoint.sh --pr…" 4 minutes ago Up 4 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp traefik

Any ideas as to what I screwed up?

Thanks, Ray

Collapse
 
adrienpoly profile image
Adrien Poly

Are you able to run

ssh root@server-ip

Collapse
 
dotenv profile image
Dotenv

make sure force_ssl is set to false on your Rails app - until you are ready to wire up your domain and add ssl termination.

Collapse
 
nickisnoble profile image
Nick Noble

Is there an easy way to ask kamal to configure SSL?

(Does it happen on the hetzner server, or inside the image?)

Collapse
 
rpaweb profile image
Rafael Peña-Azar, M.Sc.Eng.

Excellent article!!! Everything very well explained and detailed. Kudos!!!

The only thing with me rn is that I try to connect via ssh root@ip and even with SSH key already configured and added into the server config in hetzner cloud, I only can enter the console inside hetzner webapp, but not in my local console from my mbp. Same pass. On hetzner's cloud app works, but on my mbp in local, doesn't. Still trying to process what can be the error or the mistake I'm making.

Collapse
 
skylerptp profile image
Skyler

It dosen't work actually if do as same as you did

Collapse
 
adrienpoly profile image
Adrien Poly

What are your specific errors? What dit you try ?

Collapse
 
dotenv profile image
Dotenv

good article. thanks.

Collapse
 
kozubenko profile image
Andrew Kozubenko

What is a right way to run migrations on each kamal deploy?