Skip to content

Hosting n8n on Heroku#

This hosting guide shows you how to self-host n8n on Heroku. It uses:

  • Docker Compose to create and define the application components and how they work together.
  • Heroku's PostgreSQL service to host n8n's data storage.
  • A Deploy to Heroku button offering a one click, with minor configuration, deployment.

Self-hosting knowledge prerequisites

Self-hosting n8n requires technical knowledge, including:

  • Setting up and configuring servers and containers
  • Managing application resources and scaling
  • Securing servers and applications
  • Configuring n8n

n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends n8n Cloud.

Latest and Next versions

n8n releases a new minor version most weeks. The latest version is for production use. next is the most recent release. You should treat next as a beta: it may be unstable. To report issues, use the forum.

Current latest: 1.38.1
Current next: 1.39.0

Use the deployment template to create a Heroku project#

The quickest way to get started with deploying n8n to Heroku is using the Deploy to Heroku button:

Deploy

This opens the Create New App page on Heroku. Set a name for the project, and choose the region to deploy the project to.

Configure environment variables#

Heroku pre-fills the configuration options defined in the env section of the app.json file, which also sets default values for the environment variables n8n uses.

You can change any of these values to suit your needs. You must change the following values:

  • N8N_ENCRYPTION_KEY, which n8n uses to encrypt user account details before saving to the database.
  • WEBHOOK_URL should match the application name you create to ensure that webhooks have the correct URL.

Deploy n8n#

Select Deploy app.

After Heroku builds and deploys the app it provides links to Manage App or View the application.

Heroku and DNS

Refer to the Heroku documentation to find out how to connect your domain to a Heroku application.

Changing the deployment template#

You can make changes to the deployment template by forking the repository and deploying from you fork.

The Dockerfile#

By default the Dockerfile pulls the latest n8n image, if you want to use a different or fixed version, then update the image tag on the top line of the Dockerfile.

Heroku and exposing ports#

Heroku doesn't allow Docker-based applications to define an exposed port with the EXPOSE command. Instead, Heroku provides a PORT environment variable that it dynamically populates at application runtime. The entrypoint.sh file overrides the default Docker image command to instead set the port variable that Heroku provides. You can then access n8n on port 80 in a web browser.

Docker limitations with Heroku

Read this guide for more details on the limitations of using Docker with Heroku.

Configuring Heroku#

The heroku.yml file defines the application you want to create on Heroku. It consists of two sections:

  • setup > addons defines the Heroku addons to use. In this case, the PostgreSQL database addon.
  • The build section defines how Heroku builds the application. In this case it uses the Docker buildpack to build a web service based on the supplied Dockerfile.

Next steps#