How to Deploy or Run n8n on Heroku: Step-by-Step Guide

Introduction

In an age where digital tools and apps multiply rapidly, managing multiple services manually can become overwhelming. Imagine having a personal assistant that connects all your apps and automates repetitive tasks for you — that’s exactly what n8n does. Pronounced “n-eight-n,” n8n is an open-source workflow automation tool that lets you link together hundreds of apps like Gmail, Slack, Google Sheets, Twitter, and many more, without writing complex code.

The power of n8n lies in its flexibility. You can create workflows visually by dragging and dropping nodes that represent different apps or actions. For example, you might set up a workflow to automatically save email attachments to Dropbox or send notifications to Slack when a new order is placed in your e-commerce store. If you want control, customization, and transparency — n8n is a great choice.

But to truly harness the power of n8n, you need to run it somewhere. Hosting your own instance means you control your data and can customize the tool without limits. While you can run n8n on your own computer or server, many people prefer cloud platforms for ease of use and availability.

This is where Heroku shines. Heroku is a cloud platform that lets you deploy apps with a few commands. Its free tier offers an excellent playground to run small projects or prototypes without needing to manage servers or infrastructure. You can get your n8n instance online and accessible from anywhere in minutes.

This step-by-step guide will take you through deploying n8n on Heroku from scratch. We’ll cover everything — from cloning the repository to configuring your app, securing it, and tips for production use. Whether you’re a developer wanting to experiment or a business user seeking simple automation, this guide is tailored for you.

Prerequisites

Before we jump in, let’s make sure you have everything you need:

Basic Knowledge of Git and Heroku

  • Git is a version control system used to track changes in code. You’ll use it to clone the n8n code repository and push changes to Heroku.
  • Heroku is a Platform as a Service (PaaS) that abstracts away server management, letting you deploy apps with simple commands.

If you’re new to these tools, no worries — just follow online tutorials or check Heroku’s and Git’s official docs to get comfortable.

A Heroku Account

Create a free account at heroku.com. The free tier gives you enough resources to run small apps and learn the platform.

Heroku CLI Installed

The Heroku Command Line Interface (CLI) lets you interact with your apps from your computer’s terminal.

Git Installed

If you don’t have Git installed yet, download it from git-scm.com and follow installation instructions.

Node.js Installed Locally (Optional)

Node.js is the JavaScript runtime that powers n8n. While you don’t strictly need it for deploying on Heroku, having Node.js installed allows you to test and modify n8n locally before deployment.

Download from nodejs.org.

Fork or Clone the n8n Repository

n8n is open-source, and its code lives on GitHub. To deploy it on Heroku, you first need to get a copy of this code.

Cloning the Repository

Open your terminal or command prompt and run:

Bash
git clone https://github.com/n8n-io/n8n.git
cd n8n

This command downloads the entire n8n codebase to your local machine and moves into the project directory.

Why Clone Instead of Download?

Cloning the repository via Git is preferred because it keeps a link to the original project. You can easily pull updates later or contribute improvements back.

Optional: Forking

If you plan to customize n8n heavily or contribute changes upstream, you might want to fork the repository on GitHub first, then clone your fork.

Prepare the App for Heroku Deployment

Heroku expects certain files and configurations to know how to run your app.

Create a Procfile

A Procfile tells Heroku which commands to run when starting your application. In the root directory of the cloned repo, run:

Bash
echo "web: n8n" > Procfile

This means Heroku will launch n8n as a web process, which is necessary since n8n serves its UI and workflows over HTTP.

Why is the Procfile Important?

Without it, Heroku wouldn’t know how to start your app, and your deployment would fail.

Set Environment to Production

Heroku sets the NODE_ENV environment variable to production automatically. This optimizes the app by disabling development features and improving performance.

If you run n8n locally for testing, make sure to set:

Bash
export NODE_ENV=production

on macOS/Linux or the equivalent on Windows.

Modify package.json Scripts (Optional)

The package.json file contains scripts used for building and running n8n. Usually, no changes are needed for Heroku deployment. However, if you want to customize startup commands or build steps, this is where to do it.

Keep in Mind

  • Heroku requires at least one web dyno to run your app continuously.
  • Free-tier dynos “sleep” after 30 minutes of inactivity (more on this later).

Configure Environment Variables

Environment variables (env vars) are how you configure your n8n app without hardcoding sensitive or environment-specific info into code.

Key Environment Variables for n8n on Heroku

VariablePurpose
N8N_BASIC_AUTH_USERUsername for basic HTTP authentication
N8N_BASIC_AUTH_PASSWORDPassword for basic HTTP authentication
N8N_HOSTYour Heroku app’s hostname or domain (usually auto-set)
N8N_PORTPort on which n8n will listen (Heroku sets automatically)
WEBHOOK_TUNNEL_URLURL to expose webhook nodes if no custom domain
N8N_EDITOR_BASE_URLBase URL of the n8n editor UI, usually your Heroku URL

Why Use Basic Auth?

Because your n8n instance is accessible over the internet, you must protect it from unauthorized access. Basic authentication provides a simple username/password prompt when visiting the app.

How to Set Environment Variables on Heroku

Using the Heroku CLI, you can set variables like this:

Bash
heroku config:set N8N_BASIC_AUTH_USER=youruser N8N_BASIC_AUTH_PASSWORD=yourpass

You can add additional variables similarly:

Bash
heroku config:set N8N_EDITOR_BASE_URL=https://your-app-name.herokuapp.com

Tips for Secure Credentials

  • Use strong, hard-to-guess passwords.
  • Never commit secrets to your Git repo.
  • Rotate credentials periodically.

How to View or Change Variables Later

List all variables:

Bash
heroku config

Unset a variable:

Bash
heroku config:unset VARIABLE_NAME

Deploy to Heroku

Now comes the exciting part — launching your app on the cloud.

Create Your Heroku App

Run this command:

Bash
heroku create your-app-name

Replace your-app-name with something unique. Heroku will respond with your app’s URL and git remote information.

If you skip the app name, Heroku will generate a random one for you.

Push Code to Heroku

With the app created, push your code from your local repo to Heroku’s remote:

Bash
git push heroku main

This triggers Heroku to build and deploy your app.

Note: If your branch is called master instead of main, adjust accordingly:

Bash
git push heroku master

Scale the Web Dyno

Make sure at least one web dyno is running:

Bash
heroku ps:scale web=1

This ensures your n8n instance stays alive and accessible.

Monitor Logs

To check app logs and debug issues, run:

Bash
heroku logs --tail

This is useful if your app doesn’t start correctly or you want to see workflow activity.

Access Your n8n Instance

Once deployed and running, open your app’s URL:

Bash
heroku open

This opens your default browser to your n8n web interface.

Log In Using Basic Auth

You’ll be prompted for the username and password you configured earlier with the environment variables.

What You See Next

The n8n editor UI loads. Here you can build, run, and manage workflows visually.

Create Your First Workflow

A simple workflow might be:

  • Trigger: Google Sheets new row added
  • Action: Send an email notification

You drag nodes onto the canvas, connect them, configure credentials, and execute.

Tips for Getting Started

  • Explore the node library to see supported integrations.
  • Use the documentation to learn node-specific configurations.
  • Test workflows thoroughly before relying on them in production.

Optional – Use PostgreSQL or S3 for Production

For serious automation projects or production workloads, consider enhancing your n8n setup.

Why Use PostgreSQL?

By default, n8n stores data locally on disk, which is ephemeral on Heroku. Using a PostgreSQL database lets you persist workflow executions, credentials, and data safely.

Add Heroku Postgres Add-on

Run:

Bash
heroku addons:create heroku-postgresql:hobby-dev

This provisions a free PostgreSQL database attached to your app.

Configure n8n for PostgreSQL

Set environment variables like:

Bash
heroku config:set DB_TYPE=postgresdb
heroku config:set DB_POSTGRESDB_HOST=<host>
heroku config:set DB_POSTGRESDB_PORT=<port>
heroku config:set DB_POSTGRESDB_DATABASE=<database>
heroku config:set DB_POSTGRESDB_USER=<user>
heroku config:set DB_POSTGRESDB_PASSWORD=<password>

You get these details from the Heroku Postgres dashboard or by running:

Bash
heroku config:get DATABASE_URL

Use S3 for File Storage

If your workflows handle files, consider offloading storage to Amazon S3. You can configure n8n to use S3-compatible storage services, reducing risk of data loss.

Handle Dyno Sleeping

Free Heroku dynos sleep after 30 minutes of inactivity, which can cause delays as the app wakes up. For production use:

  • Upgrade to paid dynos (no sleeping)
  • Use Heroku Scheduler add-on to ping your app regularly
  • Use external uptime monitors to keep the app awake

Security and Limitations

Security Tips

  • Always enable Basic Authentication to restrict access.
  • Use HTTPS (Heroku apps default to HTTPS) to encrypt data in transit.
  • Do not store sensitive credentials in workflows; use environment variables or n8n’s credential management.
  • Regularly update n8n to get security patches.

Heroku Free Tier Limitations

  • Dyno sleeping: Causes downtime after inactivity.
  • Ephemeral filesystem: Files saved locally may be lost on restart.
  • Resource limits: CPU and memory are limited on free dynos, which may affect performance for large workflows.

For critical or heavy use, consider paid plans or other hosting solutions.

Conclusion

Deploying n8n on Heroku is a straightforward way to get powerful automation running in the cloud without complex server setups. This setup is especially great for:

  • Testing new workflows quickly
  • Prototyping automation ideas
  • Small projects or personal use

What We Covered:

  • Installing prerequisites and tools
  • Cloning and preparing the n8n code
  • Configuring environment variables securely
  • Deploying and scaling on Heroku
  • Accessing and using your n8n instance
  • Optional tips for production readiness with PostgreSQL and S3
  • Important security considerations and Heroku’s limitations

Looking Ahead

If your automation needs grow, or if uptime and data persistence are critical, you might explore:

  • Running n8n in Docker containers on VPS or cloud providers like AWS, DigitalOcean, or Google Cloud
  • Using managed n8n hosting services that handle scaling and security
  • Combining n8n with other tools like Kubernetes for large-scale automation

With your own n8n instance live on Heroku, you’re now empowered to automate workflows that save time and reduce manual work. The possibilities are vast — from business processes to personal productivity hacks.