Arief's Blog

Deploy n8n on Fly.io

Below, you can see the fly.toml file that I used to deploy n8n on Fly.io. It assumes that you already have a Postgres database.

app = '<update-this>'
primary_region = 'sin'
kill_signal = 'SIGINT'
kill_timeout = '5s'

[build]
  image = 'n8nio/n8n:stable'

[env]
  DB_POSTGRESDB_DATABASE = '<update-this>'
  DB_POSTGRESDB_HOST = '<update-this>'
  DB_POSTGRESDB_PASSWORD = '<update-this>'
  DB_POSTGRESDB_PORT = '5432'
  DB_POSTGRESDB_SSL_ENABLED = 'true'
  DB_POSTGRESDB_USER = '<update-this>'
  DB_TYPE = 'postgresdb'

  GENERIC_TIMEZONE = 'Asia/Jakarta'
  TZ = 'Asia/Jakarta'

  N8N_DIAGNOSTICS_ENABLED = 'false'
  N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS = 'false'
  N8N_HIRING_BANNER_ENABLED = 'false'
  N8N_HOST = '<update-this>.fly.dev'
  N8N_PORT = '5678'
  N8N_PROTOCOL = 'https'
  N8N_RUNNERS_ENABLED = 'true'
  WEBHOOK_URL = '<update-this>.fly.dev'

  TINI_SUBREAPER = 'true'

[[mounts]]
  source = 'n8n_data'
  destination = '/home/node/.n8n'

[[services]]
  protocol = 'tcp'
  internal_port = 5678
  processes = ['app']

  [[services.ports]]
    port = 443
    handlers = ['tls', 'http']

  [[services.ports]]
    port = 80
    handlers = ['http']
    force_https = true

  [services.concurrency]
    type = 'connections'
    hard_limit = 100
    soft_limit = 50

  [[services.tcp_checks]]
    interval = '15s'
    timeout = '2s'
    grace_period = '1s'

[[vm]]
  memory = '1gb'
  cpu_kind = 'shared'
  cpus = 1
#automation #n8n #fly.io