Hosting n8n for Free with Railway

Hosting n8n for Free with Railway

by Alex Hyett | 6 min read

I have been using n8n for a couple of months now, and it has allowed me to automate so much of my daily workflow.

These are some of the automations I now have set up with n8n:

  • When a new blog post is published with Strapi,
    • Kick off GitHub Actions to deploy blog
    • Republish Blog post to Hashnode, and Medium
    • Update my content calendar with the URL and set to Published
    • Add post to my keyword tracking spreadsheet
  • Update my content calendar when I publish a new video on YouTube
  • Schedule tweets to Twitter at the most optimum times
  • Sync my want to read books on Goodreads to an Airtable

If I were to code all of these automations myself, it would have taken more than a couple of weeks to set up each one, once you take account of infrastructure and everything else.

What is n8n?

If you haven’t heard of n8n, it is IFTTT and Zapier on steroids. It has all the same integrations as the main platforms, but also lets you call custom APIs as well write your own code to do more complicated things.

No-code tools are useful, but when you combine that with a little bit of code as well, they become incredibly powerful.

They might not be the best solution to do things at scale, that is where custom solutions really shine, but for automating your daily workflow they are incredibly useful.

Running n8n

There are a number of options for running n8n, and they all have their own pros and cons.

n8n options

Desktop Application

You can run n8n as a desktop application. This is great if you just want to try out the tool and see what you can build with it.

If you plan to run any workflows that deal with files, then you will probably need to run the desktop application.

The downside is that any workflows that you need to run on a schedule or be triggered by an external action aren’t going to work unless you leave your computer on all the time.

Cloud Host

N8n offer their own cloud option, however unless you have a lot of automations running for your business it is hard to justify the cost.

The starter plan is slightly more expensive than Zapier, but both platforms only allow you 20 workflows at around £20 a month, which seems a bit steep.

Self-Host Locally

If you have your own home server such as a Raspberry Pi or something similar, you can run n8n using Docker.

I have my own n8n running on my home server which I use for my personal automations such as backing up my Goodreads list.

If you are using Traefik as a reverse proxy you can use the following Docker compose file to set up your own instance.

version: '3.8'


    image: postgres:11
    restart: always
      - db_storage:/var/lib/postgresql/data
      - ./
      test: ['CMD-SHELL', 'pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
      interval: 5s
      timeout: 5s
      retries: 10

    image: n8nio/n8n
    restart: always
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - N8N_BASIC_AUTH_ACTIVE=true
      - WEBHOOK_URL=https://${DOMAIN_NAME}${N8N_PATH}
      - N8N_PATH=${N8N_PATH}
    #  - 5678:5678
      - postgres
      - n8n_storage:/home/node/.n8n
    command: /bin/sh -c "n8n start --tunnel"
        condition: service_healthy
      - 'traefik.enable=true'
      - 'traefik.http.routers.n8n.rule=Host(`${DOMAIN_NAME}`)'
      - 'traefik.http.routers.n8n.rule=PathPrefix(`/${SUBFOLDER}{regex:$$|/.*}`)'
      - ''
      - 'traefik.http.middlewares.n8n-stripprefix.stripprefix.prefixes=/${SUBFOLDER}'
      - 'traefik.http.routers.n8n.middlewares=n8n-stripprefix'

You will also need to set up .env file to contain all of your environment variables like this one:



Assuming that your home server is called servername then this will make n8n available on http://servername/n8n.

Self-hosting locally is useful, but if you don’t have your own server or have an unreliable internet connection, then there is a better option.

Hosting with Railway

I recently discovered Railway as hosting platform. For developers and individual use, they give you $5 of credit every month.

This is enough to cover the cost of running n8n in most cases. Obviously, if you have hundreds of workflows running all the time, it is going to use more resources.

With Railway, you are only charged for what you use, so if your instance is just running idle most of the time it isn’t going to use many resources.

Railway make it really easy to set up services using their templates. The template for n8n can be found on GitHub, and there is a button to Deploy to Railway in the readme.

If that doesn’t work, you can select New Project in Railway and search for n8n. It should come up with template.

n8n template

Enter the details and click deploy. This will kick off the build of the project.

n8n Github

After a few minutes, n8n will be deployed and Railway will show you the URL for your instance. It will look something like this

If you want to add your own domain, you can do that as well by going to the Settings tab and adding your own custom domain.

Custom Domain

Once added, you need to set up the corresponding CNAME record on your domain.

There are a few more environment variables we also need to set up before we are done. This can be done on the variables tab.

  • N8N_ENCRYPTION_KEY - If you don’t set your own encryption key, then n8n will generate a new one each time it is deployed. Which means it won’t be able to read any of the credentials that have been stored.
  • N8N_HOST - Set this to your domain. Either the custom one you have set up or the one you have been given, e.g.
  • N8N_PROTOCOL - Set this to https
  • WEBHOOK_URL - If you want to trigger any of your workflows using a webhook, then it is important to set this. For some reason for me, it didn’t set it to the n8n host e.g.

Once these have been set, Railway will deploy again and then your instance is ready to use.

Was this helpful?
If you need more help, I also have a private Discord community for my fans where they can ask me questions. As a fan, your name is included at the end of my YouTube videos as well getting exclusive content and discounts to my future courses.
🌟 Find out more about becoming a Fan
Or you could buy me a coffee ☕️ to say thank you, any support is appreciated.


Using GitHub Actions to Deploy to S3

Using GitHub Actions to Deploy to S3

  • 26 March 2021
Recently I went through the process of setting up Drone CI on my Raspberry Pi. The plan was to use my Raspberry Pi as a build server for…
Getting Started with AWS Step Functions

Getting Started with AWS Step Functions

  • 12 March 2021
I have recently been looking into AWS Step Functions. For those not familiar with them, Step Functions are Amazon’s way of providing a state…
Useful Docker Commands Worth Saving

Useful Docker Commands Worth Saving

  • 12 February 2021
I use docker every day. All the applications I write at work or at home end up in docker containers. Most of the time though, I am only…
Grafana Monitoring on a Raspberry Pi

Grafana Monitoring on a Raspberry Pi

  • 28 January 2021
As you might have seen from my last few posts I have quite a lot running on my Raspberry Pi. I am currently using a Raspberry Pi 2 B which…
How to set up Drone CI on Raspberry Pi (and why you shouldn't)

How to set up Drone CI on Raspberry Pi (and why you shouldn't)

  • 27 January 2021
I wanted to put together my home build server using my Raspberry Pi. After looking at the options I picked Drone CI, it has a nice interface…
Traefik vs Nginx for Reverse Proxy with Docker on a Raspberry Pi

Traefik vs Nginx for Reverse Proxy with Docker on a Raspberry Pi

  • 20 January 2021
I use my Raspberry Pi as my own personal home server. Up until recently, I have been using nginx as a reverse proxy for my docker containers…
Hosting a Secure Static Website on AWS S3 using Terraform (Step By Step Guide)

Hosting a Secure Static Website on AWS S3 using Terraform (Step By Step Guide)

  • 14 January 2021
By the time you finish reading this article, you will know how to get your static websites up and running securely on AWS using Terraform…
Creating a contact form with AWS Lambda and .Net Core

Creating a contact form with AWS Lambda and .Net Core

  • 13 December 2018
I recently switched my website over from a standard Wordpress installation to a static site built with Gatsby.js and React. With Gatsby.js…