{
  "manifest_version": "1.0.0",
  "template": {
    "id": "922efa11-8133-435a-b511-2cebfa916ae7",
    "slug": "n8n-or-self-hosted-automation-with-postg",
    "name": "n8n | Self-Hosted Automation with Postgres and Real Persistence",
    "description": "Self-host n8n on Railway — workflows, Postgres & data that survives.",
    "url": "https://railway.com/deploy/n8n-or-self-hosted-automation-with-postg",
    "upstream": {
      "image": "n8nio/n8n:2.36.0"
    }
  },
  "status": "unvalidated",
  "validated_at": null,
  "success_rate_30d": null,
  "services": [
    {
      "name": "Postgres",
      "source": {
        "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
      },
      "needs_volume": true,
      "volume_mount_path": "/var/lib/postgresql/data",
      "tcp_ports": [
        5432
      ],
      "http": false
    },
    {
      "name": "n8n",
      "source": {
        "image": "n8nio/n8n:2.36.0"
      },
      "needs_volume": true,
      "volume_mount_path": "/home/node/.n8n",
      "http": true
    }
  ],
  "required_inputs": [
    {
      "key": "PGDATA",
      "service": "Postgres",
      "description": "Location where the database will be initialized",
      "secret": false,
      "strategy": "default",
      "default": "/var/lib/postgresql/data/pgdata"
    },
    {
      "key": "PGHOST",
      "service": "Postgres",
      "description": "Railway Private Domain Name.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "PGPORT",
      "service": "Postgres",
      "description": "Port to connect to Postgres.",
      "secret": false,
      "strategy": "default",
      "default": "5432"
    },
    {
      "key": "PGUSER",
      "service": "Postgres",
      "description": "Required variable for Data panel",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGDATABASE",
      "service": "Postgres",
      "description": "Required variable for the data panel.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGPASSWORD",
      "service": "Postgres",
      "description": "Required variable for Data panel",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "POSTGRES_DB",
      "service": "Postgres",
      "description": "Default database created when image is started.",
      "secret": false,
      "strategy": "default",
      "default": "railway"
    },
    {
      "key": "DATABASE_URL",
      "service": "Postgres",
      "description": "URL to connect to Postgres database.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "POSTGRES_USER",
      "service": "Postgres",
      "description": "User to connect to Postgres DB",
      "secret": false,
      "strategy": "default",
      "default": "postgres"
    },
    {
      "key": "SSL_CERT_DAYS",
      "service": "Postgres",
      "description": "SSL certificate expiry in days.",
      "secret": false,
      "strategy": "default",
      "default": "820"
    },
    {
      "key": "POSTGRES_PASSWORD",
      "service": "Postgres",
      "description": "Password to connect to DB",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "DATABASE_PUBLIC_URL",
      "service": "Postgres",
      "description": "Public URL to connect to Postgres database, used by the Data panel.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "RAILWAY_DEPLOYMENT_DRAINING_SECONDS",
      "service": "Postgres",
      "description": "Allow Postgres to cleanly shut down",
      "secret": false,
      "strategy": "default",
      "default": "60"
    },
    {
      "key": "PORT",
      "service": "n8n",
      "description": "Provide a value for PORT.",
      "secret": false,
      "strategy": "default",
      "default": "5678"
    },
    {
      "key": "DB_TYPE",
      "service": "n8n",
      "description": "Provide a value for DB_TYPE.",
      "secret": false,
      "strategy": "default",
      "default": "postgresdb"
    },
    {
      "key": "N8N_PORT",
      "service": "n8n",
      "description": "Provide a value for N8N_PORT.",
      "secret": false,
      "strategy": "default",
      "default": "5678"
    },
    {
      "key": "NODE_OPTIONS",
      "service": "n8n",
      "description": "Caps the V8 heap so the first boot, which runs every database migration at once, stays under the 1 GB per-service memory ceiling of the Railway Trial plan.",
      "secret": false,
      "strategy": "default",
      "default": "--max-old-space-size=768"
    },
    {
      "key": "N8N_USER_FOLDER",
      "service": "n8n",
      "description": "Provide a value for N8N_USER_FOLDER.",
      "secret": false,
      "strategy": "default",
      "default": "/home/node"
    },
    {
      "key": "N8N_WEBHOOK_URL",
      "service": "n8n",
      "description": "Provide a value for N8N_WEBHOOK_URL.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_domain"
    },
    {
      "key": "RAILWAY_RUN_UID",
      "service": "n8n",
      "description": "Provide a value for RAILWAY_RUN_UID.",
      "secret": false,
      "strategy": "default",
      "default": "0"
    },
    {
      "key": "GENERIC_TIMEZONE",
      "service": "n8n",
      "description": "Provide a value for GENERIC_TIMEZONE.",
      "secret": false,
      "strategy": "default",
      "default": "UTC"
    },
    {
      "key": "DB_POSTGRESDB_HOST",
      "service": "n8n",
      "description": "Provide a value for DB_POSTGRESDB_HOST.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DB_POSTGRESDB_PORT",
      "service": "n8n",
      "description": "Provide a value for DB_POSTGRESDB_PORT.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DB_POSTGRESDB_USER",
      "service": "n8n",
      "description": "Provide a value for DB_POSTGRESDB_USER.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "N8N_ENCRYPTION_KEY",
      "service": "n8n",
      "description": "Provide a value for N8N_ENCRYPTION_KEY.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    },
    {
      "key": "N8N_LISTEN_ADDRESS",
      "service": "n8n",
      "description": "Provide a value for N8N_LISTEN_ADDRESS.",
      "secret": false,
      "strategy": "default",
      "default": "::"
    },
    {
      "key": "N8N_EDITOR_BASE_URL",
      "service": "n8n",
      "description": "Provide a value for N8N_EDITOR_BASE_URL.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_domain"
    },
    {
      "key": "EXECUTIONS_DATA_PRUNE",
      "service": "n8n",
      "description": "Deletes old execution records so Postgres does not grow without bound on a small plan.",
      "secret": false,
      "strategy": "default",
      "default": "true"
    },
    {
      "key": "DB_POSTGRESDB_DATABASE",
      "service": "n8n",
      "description": "Provide a value for DB_POSTGRESDB_DATABASE.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DB_POSTGRESDB_PASSWORD",
      "service": "n8n",
      "description": "Provide a value for DB_POSTGRESDB_PASSWORD.",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "N8N_DEFAULT_BINARY_DATA_MODE",
      "service": "n8n",
      "description": "Keeps binary data from executions on the volume instead of in memory and Postgres, so large files do not blow up the container or the database.",
      "secret": false,
      "strategy": "default",
      "default": "filesystem"
    },
    {
      "key": "EXECUTIONS_DATA_PRUNE_MAX_COUNT",
      "service": "n8n",
      "description": "How many past executions to keep when pruning is on. Raise it if you need a longer history.",
      "secret": false,
      "strategy": "default",
      "default": "200"
    },
    {
      "key": "DB_POSTGRESDB_CONNECTION_TIMEOUT",
      "service": "n8n",
      "description": "Milliseconds to wait for Postgres on start, raised from the 20s default so a slow first boot of the database does not fail the deploy.",
      "secret": false,
      "strategy": "default",
      "default": "60000"
    }
  ],
  "deploy": {
    "mcp": {
      "server": "railway",
      "tool": "deploy_template",
      "args": {
        "template_code": "n8n-or-self-hosted-automation-with-postg"
      }
    },
    "cli": "railway deploy --template n8n-or-self-hosted-automation-with-postg",
    "api": {
      "method": "POST",
      "path": "/graphql/v2",
      "body": {
        "query": "mutation templateDeploy($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }",
        "variables": {
          "input": {
            "templateId": "922efa11-8133-435a-b511-2cebfa916ae7",
            "serializedConfig": {
              "services": {
                "7ffc2c85-e3bc-4859-bfd3-0a7ec391a005": {
                  "icon": "https://devicons.railway.app/i/postgresql.svg",
                  "name": "Postgres",
                  "build": {},
                  "deploy": {
                    "requiredMountPath": "/var/lib/postgresql/data"
                  },
                  "source": {
                    "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
                  },
                  "variables": {
                    "PGDATA": {
                      "isOptional": false,
                      "description": "Location where the database will be initialized",
                      "defaultValue": "/var/lib/postgresql/data/pgdata"
                    },
                    "PGHOST": {
                      "isOptional": false,
                      "description": "Railway Private Domain Name.",
                      "defaultValue": "${{RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "PGPORT": {
                      "isOptional": false,
                      "description": "Port to connect to Postgres.",
                      "defaultValue": "5432"
                    },
                    "PGUSER": {
                      "isOptional": false,
                      "description": "Required variable for Data panel",
                      "defaultValue": "${{ POSTGRES_USER }}"
                    },
                    "PGDATABASE": {
                      "isOptional": false,
                      "description": "Required variable for the data panel.",
                      "defaultValue": "${{POSTGRES_DB}}"
                    },
                    "PGPASSWORD": {
                      "isOptional": false,
                      "description": "Required variable for Data panel",
                      "defaultValue": "${{POSTGRES_PASSWORD}}"
                    },
                    "POSTGRES_DB": {
                      "isOptional": false,
                      "description": "Default database created when image is started.",
                      "defaultValue": "railway"
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "URL to connect to Postgres database.",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/${{PGDATABASE}}"
                    },
                    "POSTGRES_USER": {
                      "isOptional": false,
                      "description": "User to connect to Postgres DB",
                      "defaultValue": "postgres"
                    },
                    "SSL_CERT_DAYS": {
                      "isOptional": true,
                      "description": "SSL certificate expiry in days.",
                      "defaultValue": "820"
                    },
                    "POSTGRES_PASSWORD": {
                      "isOptional": false,
                      "description": "Password to connect to DB",
                      "defaultValue": "{{POSTGRES_PASSWORD}}"
                    },
                    "DATABASE_PUBLIC_URL": {
                      "description": "Public URL to connect to Postgres database, used by the Data panel.",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_TCP_PROXY_DOMAIN}}:${{RAILWAY_TCP_PROXY_PORT}}/${{PGDATABASE}}"
                    },
                    "RAILWAY_DEPLOYMENT_DRAINING_SECONDS": {
                      "isOptional": false,
                      "description": "Allow Postgres to cleanly shut down",
                      "defaultValue": "60"
                    }
                  },
                  "networking": {
                    "tcpProxies": {
                      "5432": {}
                    },
                    "serviceDomains": {}
                  },
                  "volumeMounts": {
                    "7ffc2c85-e3bc-4859-bfd3-0a7ec391a005": {
                      "mountPath": "/var/lib/postgresql/data"
                    }
                  },
                  "haTemplateCode": "postgres-ha",
                  "haConversionConfig": {
                    "edge": {
                      "label": "Reverse Proxy",
                      "options": [
                        2,
                        3,
                        4,
                        5
                      ],
                      "nodeLabel": "HAProxy",
                      "description": "Routes traffic to the primary",
                      "defaultValue": 3
                    },
                    "replica": {
                      "label": "Replicas",
                      "options": [
                        2,
                        3,
                        4,
                        5,
                        6,
                        7
                      ],
                      "nodeLabel": "Postgres",
                      "description": "Streaming replicas for automatic failover",
                      "defaultValue": 2
                    },
                    "internal": {
                      "label": "Coordinator Nodes",
                      "options": [
                        3,
                        5,
                        7,
                        9
                      ],
                      "nodeLabel": "etcd",
                      "defaultValue": 3
                    },
                    "description": "This will convert your Postgres database to an HA cluster with Patroni failover and etcd consensus."
                  }
                },
                "aed736a2-93a4-4f2e-a77d-7234b91ffac2": {
                  "icon": "https://devicons.railway.com/i/n8n.svg",
                  "name": "n8n",
                  "deploy": {
                    "healthcheckPath": "/healthz"
                  },
                  "source": {
                    "image": "n8nio/n8n:2.36.0"
                  },
                  "variables": {
                    "PORT": {
                      "isOptional": false,
                      "description": "",
                      "defaultValue": "5678"
                    },
                    "DB_TYPE": {
                      "defaultValue": "postgresdb"
                    },
                    "N8N_PORT": {
                      "defaultValue": "5678"
                    },
                    "NODE_OPTIONS": {
                      "isOptional": false,
                      "description": "Caps the V8 heap so the first boot, which runs every database migration at once, stays under the 1 GB per-service memory ceiling of the Railway Trial plan.",
                      "defaultValue": "--max-old-space-size=768"
                    },
                    "N8N_USER_FOLDER": {
                      "description": "",
                      "defaultValue": "/home/node"
                    },
                    "N8N_WEBHOOK_URL": {
                      "description": "",
                      "defaultValue": "https://${{RAILWAY_PUBLIC_DOMAIN}}"
                    },
                    "RAILWAY_RUN_UID": {
                      "defaultValue": "0"
                    },
                    "GENERIC_TIMEZONE": {
                      "defaultValue": "UTC"
                    },
                    "DB_POSTGRESDB_HOST": {
                      "defaultValue": "${{Postgres.PGHOST}}"
                    },
                    "DB_POSTGRESDB_PORT": {
                      "defaultValue": "${{Postgres.PGPORT}}"
                    },
                    "DB_POSTGRESDB_USER": {
                      "defaultValue": "${{Postgres.POSTGRES_USER}}"
                    },
                    "N8N_ENCRYPTION_KEY": {
                      "defaultValue": "{{N8N_ENCRYPTION_KEY}}"
                    },
                    "N8N_LISTEN_ADDRESS": {
                      "defaultValue": "::"
                    },
                    "N8N_EDITOR_BASE_URL": {
                      "defaultValue": "https://${{RAILWAY_PUBLIC_DOMAIN}}"
                    },
                    "EXECUTIONS_DATA_PRUNE": {
                      "isOptional": false,
                      "description": "Deletes old execution records so Postgres does not grow without bound on a small plan.",
                      "defaultValue": "true"
                    },
                    "DB_POSTGRESDB_DATABASE": {
                      "defaultValue": "${{Postgres.POSTGRES_DB}}"
                    },
                    "DB_POSTGRESDB_PASSWORD": {
                      "defaultValue": "${{Postgres.POSTGRES_PASSWORD}}"
                    },
                    "N8N_DEFAULT_BINARY_DATA_MODE": {
                      "isOptional": false,
                      "description": "Keeps binary data from executions on the volume instead of in memory and Postgres, so large files do not blow up the container or the database.",
                      "defaultValue": "filesystem"
                    },
                    "EXECUTIONS_DATA_PRUNE_MAX_COUNT": {
                      "isOptional": false,
                      "description": "How many past executions to keep when pruning is on. Raise it if you need a longer history.",
                      "defaultValue": "200"
                    },
                    "DB_POSTGRESDB_CONNECTION_TIMEOUT": {
                      "isOptional": false,
                      "description": "Milliseconds to wait for Postgres on start, raised from the 20s default so a slow first boot of the database does not fail the deploy.",
                      "defaultValue": "60000"
                    }
                  },
                  "networking": {
                    "serviceDomains": {
                      "<hasDomain>:5678": {
                        "port": 5678
                      }
                    }
                  },
                  "volumeMounts": {
                    "aed736a2-93a4-4f2e-a77d-7234b91ffac2": {
                      "mountPath": "/home/node/.n8n"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "post_deploy": {
    "healthcheck": {
      "service": "n8n",
      "method": "GET",
      "path": "/healthz",
      "expect_status": 200
    }
  },
  "resources": {
    "expected_services": 2,
    "needs_volume": true
  },
  "generated_at": "2026-09-04T17:54:19.363Z",
  "generator_version": "0.1.0"
}
