How to successfully deploy n8n workflow automation to Heroku platform

I’m running into issues when trying to get n8n running on Heroku using Docker containers. The deployment keeps failing and I can’t pinpoint the exact problem. I’ve tried different configurations but still getting errors.

Here’s my setup process:

First I create a PostgreSQL database:

heroku addons:create heroku-postgresql:hobby-dev --version=11 -a workflow-app

My Docker configuration:

FROM n8nio/n8n

Configuration in heroku.yml:

setup:
  config:
    APP_SUBDOMAIN: "workflow-app"
    DOMAIN_NAME: "herokuapp.com"
    NODE_ENV: "production"
    TZ: "America/New_York"
    GENERIC_TIMEZONE: "America/New_York"
    N8N_HOST: "${APP_SUBDOMAIN}.${DOMAIN_NAME}"
    N8N_PORT: "${PORT}"
    N8N_PROTOCOL: "https"
    N8N_ENCRYPTION_KEY: "myencryptionkey123"
    WEBHOOK_TUNNEL_URL: "https://${APP_SUBDOMAIN}.${DOMAIN_NAME}/"
    VUE_APP_URL_BASE_API: "https://${APP_SUBDOMAIN}.${DOMAIN_NAME}/"
    DB_TYPE: "postgresdb"
    DB_POSTGRESDB_HOST: "postgres-host"
    DB_POSTGRESDB_DATABASE: "postgres-db"
    DB_POSTGRESDB_PORT: 5432
    DB_POSTGRESDB_USER: "postgres-user"
    DB_POSTGRESDB_PASSWORD: "postgres-pwd"

build:
  docker:
    web: Dockerfile

Error messages from logs:

2020-04-15T11:19:50.178271+00:00 app[web.1]: [WARN  tini (3)] Tini is not running as PID 1
2020-04-15T11:19:50.179480+00:00 app[web.1]: su-exec: setgroups: Operation not permitted
2020-04-15T11:24:54.478493+00:00 heroku[router]: at=error code=H10 desc="App crashed"

Any suggestions on how to fix this deployment issue?

yeah, your heroku.yml looks wrong. skip the variable substitution in setup n use heroku config:set for env vars instead. also, heroku automatically sets DATABASE_URL for postgres, so just use that for your connection.

Your Dockerfile’s the problem. The base n8n image doesn’t play nice with Heroku’s process management. I ran into this exact issue and fixed it by using a custom CMD that skips tini entirely:

FROM n8nio/n8n
USER root
CMD [“n8n”, “start”]

Also, ditch the manual postgres settings and just use Heroku’s DATABASE_URL environment variable instead. That H10 error? It’s because n8n isn’t binding to Heroku’s PORT variable - it’s probably using some hardcoded port instead.

That setgroups permission error is super common with Docker on Heroku. I banged my head against this for weeks until I figured out n8n’s base image tries to change user permissions, which Heroku blocks. Fixed it with a multi-stage build - copy the n8n files but run everything as the default user. Also, those database connection variables in your heroku.yml won’t work. Heroku sets environment variables at runtime, not build time. You’ve got to parse the DATABASE_URL that Heroku gives you automatically and pull out the host, database, user, and password when your app starts up. The H10 crash is probably n8n failing to connect to the database with those placeholder values.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.