Issues with n8n deployment on Heroku platform

I’m struggling to get n8n working on Heroku using Docker containers. The deployment fails and I can’t identify the root cause. Here’s my setup:

Database setup command:

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

Docker configuration:

FROM n8nio/n8n

Application config (heroku.yml):

setup:
  config:
    SUBDOMAIN: "workflow-app"
    DOMAIN_NAME: "herokuapp.com"
    NODE_ENV: "production"
    TZ: "America/New_York"
    GENERIC_TIMEZONE: "America/New_York"
    N8N_HOST: "${SUBDOMAIN}.${DOMAIN_NAME}"
    N8N_PORT: "${PORT}"
    N8N_PROTOCOL: "https"
    N8N_ENCRYPTION_KEY: "myencryptionkey123"
    WEBHOOK_TUNNEL_URL: "https://${SUBDOMAIN}.${DOMAIN_NAME}/"
    VUE_APP_URL_BASE_API: "https://${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-password"

build:
    docker:
        web: Dockerfile

Error logs:

2020-04-15T11:19:50.178271+00:00 app[web.1]: [WARN  tini (3)] Tini is not running as PID 1 and isn't registered as a child subreaper.
2020-04-15T11:19:50.178300+00:00 app[web.1]: Zombie processes will not be re-parented to Tini, so zombie reaping won't work.
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" method=GET path="/" host=workflow-app.herokuapp.com

The app crashes on startup with H10 error. Any suggestions on what might be causing this issue?

Your heroku.yml format is wrong. Heroku doesn’t handle config vars through the heroku.yml file - you need to set them via the dashboard or CLI instead. Just keep the build section in your heroku.yml and set all those environment variables with heroku config:set commands. Also, you’re running postgres 11 which is pretty outdated - newer versions perform way better. That H10 error usually means your process isn’t binding to the right port. Make sure N8N_PORT uses Heroku’s dynamic PORT environment variable.

it might be a permission error with the docker image. heroku has limits on system calls that n8n might require. consider making a custom dockerfile that runs as non-root, or add the --init flag and see if that helps.

I ran into the same thing with n8n on Heroku. Your database config is the issue - you’re hardcoding DB_POSTGRESDB_HOST and DB_POSTGRESDB_DATABASE, but Heroku gives you these through DATABASE_URL. Parse that URL or use the config vars that get set automatically when you add the postgres addon. That encryption key is way too simple too - anyone can see Heroku logs, so generate a proper random key and store it as a config var. The setgroups error happens because the container’s trying to change user permissions, which Heroku blocks. Use the official n8n image but override the CMD to run as the existing user instead of using su-exec.