{
  "manifest_version": "1.0.0",
  "template": {
    "id": "419fea42-52a0-4c2f-8220-de3e079315c0",
    "slug": "n8n-or-self-host-or-workflow-automation",
    "name": "N8N with Postgres",
    "description": "[Jun '26] The cheapest n8n instance with database. Period.",
    "url": "https://railway.com/deploy/n8n-or-self-host-or-workflow-automation",
    "upstream": {
      "image": "n8nio/n8n"
    }
  },
  "status": "unvalidated",
  "validated_at": null,
  "success_rate_30d": null,
  "services": [
    {
      "name": "Postgres",
      "source": {
        "image": "ghcr.io/railwayapp-templates/postgres-ssl:17"
      },
      "needs_volume": true,
      "volume_mount_path": "/var/lib/postgresql/data",
      "tcp_ports": [
        5432
      ],
      "http": false
    },
    {
      "name": "n8n",
      "source": {
        "image": "n8nio/n8n"
      },
      "needs_volume": true,
      "volume_mount_path": "/data",
      "http": true
    }
  ],
  "required_inputs": [
    {
      "key": "PGDATA",
      "service": "Postgres",
      "description": "Directory inside the container where PostgreSQL stores its data files.",
      "secret": false,
      "strategy": "default",
      "default": "/var/lib/postgresql/data/pgdata"
    },
    {
      "key": "PGHOST",
      "service": "Postgres",
      "description": "Host address for connecting to the PostgreSQL database (auto-set).",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "PGPORT",
      "service": "Postgres",
      "description": "Port number PostgreSQL listens on (default: 5432).",
      "secret": false,
      "strategy": "default",
      "default": "5432"
    },
    {
      "key": "PGUSER",
      "service": "Postgres",
      "description": "Username for authenticating PostgreSQL connections.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGDATABASE",
      "service": "Postgres",
      "description": "Name of the database to connect to by default.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGPASSWORD",
      "service": "Postgres",
      "description": "Password for the PostgreSQL user account.",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "POSTGRES_DB",
      "service": "Postgres",
      "description": "Initial database name created when PostgreSQL starts for the first time.",
      "secret": false,
      "strategy": "default",
      "default": "railway"
    },
    {
      "key": "DATABASE_URL",
      "service": "Postgres",
      "description": "Full database connection URL (used by apps like n8n for easy setup).",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "POSTGRES_USER",
      "service": "Postgres",
      "description": "Default PostgreSQL user created during setup.",
      "secret": false,
      "strategy": "default",
      "default": "postgres"
    },
    {
      "key": "SSL_CERT_DAYS",
      "service": "Postgres",
      "description": "Number of days the generated SSL certificate for Postgres remains valid.",
      "secret": false,
      "strategy": "default",
      "default": "820"
    },
    {
      "key": "POSTGRES_PASSWORD",
      "service": "Postgres",
      "description": "Password assigned to the default PostgreSQL user.",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "DATABASE_PUBLIC_URL",
      "service": "Postgres",
      "description": "Publicly accessible URL for the database",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "RAILWAY_DEPLOYMENT_DRAINING_SECONDS",
      "service": "Postgres",
      "description": "Grace period (in seconds) Railway gives before shutting down the container, allowing active connections to close cleanly.",
      "secret": false,
      "strategy": "default",
      "default": "60"
    },
    {
      "key": "PORT",
      "service": "n8n",
      "description": "The HTTP port on which n8n will run. Default is 5678. Change only if it conflicts with another service.",
      "secret": false,
      "strategy": "default",
      "default": "5678"
    },
    {
      "key": "DB_TYPE",
      "service": "n8n",
      "description": "Specifies the database type used by n8n, in this case postgres.",
      "secret": false,
      "strategy": "default",
      "default": "postgresdb"
    },
    {
      "key": "N8N_PORT",
      "service": "n8n",
      "description": "Port on which the n8n service runs inside the container.",
      "secret": false,
      "strategy": "default",
      "default": "5678"
    },
    {
      "key": "WEBHOOK_URL",
      "service": "n8n",
      "description": "Public URL used by n8n to handle incoming webhooks and triggers.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_domain"
    },
    {
      "key": "DB_POSTGRESDB_HOST",
      "service": "n8n",
      "description": "Host address of the PostgreSQL database (auto-filled by Railway).",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DB_POSTGRESDB_PORT",
      "service": "n8n",
      "description": "Port number for connecting to the PostgreSQL database.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DB_POSTGRESDB_USER",
      "service": "n8n",
      "description": "Username for authenticating with the PostgreSQL database.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "EXECUTIONS_DATA_PRUNE",
      "service": "n8n",
      "description": "Enables or disables automatic cleanup of old execution records.",
      "secret": false,
      "strategy": "default",
      "default": "true"
    },
    {
      "key": "DB_POSTGRESDB_DATABASE",
      "service": "n8n",
      "description": "Name of the PostgreSQL database where n8n stores workflows and execution data.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DB_POSTGRESDB_PASSWORD",
      "service": "n8n",
      "description": "Password for the PostgreSQL user account.",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "N8N_DEFAULT_BINARY_DATA_MODE",
      "service": "n8n",
      "description": "Sets how binary files (images, PDFs, etc.) are stored — in memory or filesystem.",
      "secret": false,
      "strategy": "default",
      "default": "filesystem"
    },
    {
      "key": "EXECUTIONS_DATA_PRUNE_MAX_COUNT",
      "service": "n8n",
      "description": "Defines the maximum number of execution records to retain when pruning.",
      "secret": false,
      "strategy": "default",
      "default": "100"
    },
    {
      "key": "N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS",
      "service": "n8n",
      "description": "When enabled, ensures n8n settings files have secure access permissions (for safety).",
      "secret": false,
      "strategy": "default",
      "default": "true"
    }
  ],
  "deploy": {
    "mcp": {
      "server": "railway",
      "tool": "deploy_template",
      "args": {
        "template_code": "n8n-or-self-host-or-workflow-automation"
      }
    },
    "cli": "railway deploy --template n8n-or-self-host-or-workflow-automation",
    "api": {
      "method": "POST",
      "path": "/graphql/v2",
      "body": {
        "query": "mutation templateDeploy($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }",
        "variables": {
          "input": {
            "templateId": "419fea42-52a0-4c2f-8220-de3e079315c0",
            "serializedConfig": {
              "services": {
                "cb9775ae-ccea-4dc7-80be-6232ab79abc7": {
                  "icon": "https://devicons.railway.app/i/postgresql.svg",
                  "name": "Postgres",
                  "deploy": {
                    "startCommand": null,
                    "healthcheckPath": null
                  },
                  "source": {
                    "image": "ghcr.io/railwayapp-templates/postgres-ssl:17"
                  },
                  "variables": {
                    "PGDATA": {
                      "isOptional": false,
                      "description": "Directory inside the container where PostgreSQL stores its data files.",
                      "defaultValue": "/var/lib/postgresql/data/pgdata"
                    },
                    "PGHOST": {
                      "isOptional": false,
                      "description": "Host address for connecting to the PostgreSQL database (auto-set).",
                      "defaultValue": "${{RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "PGPORT": {
                      "isOptional": false,
                      "description": "Port number PostgreSQL listens on (default: 5432).",
                      "defaultValue": "5432"
                    },
                    "PGUSER": {
                      "isOptional": false,
                      "description": "Username for authenticating PostgreSQL connections.",
                      "defaultValue": "${{POSTGRES_USER}}"
                    },
                    "PGDATABASE": {
                      "isOptional": false,
                      "description": "Name of the database to connect to by default.",
                      "defaultValue": "${{POSTGRES_DB}}"
                    },
                    "PGPASSWORD": {
                      "isOptional": false,
                      "description": "Password for the PostgreSQL user account.",
                      "defaultValue": "${{POSTGRES_PASSWORD}}"
                    },
                    "POSTGRES_DB": {
                      "isOptional": false,
                      "description": "Initial database name created when PostgreSQL starts for the first time.",
                      "defaultValue": "railway"
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "Full database connection URL (used by apps like n8n for easy setup).",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/${{PGDATABASE}}"
                    },
                    "POSTGRES_USER": {
                      "isOptional": false,
                      "description": "Default PostgreSQL user created during setup.",
                      "defaultValue": "postgres"
                    },
                    "SSL_CERT_DAYS": {
                      "isOptional": false,
                      "description": "Number of days the generated SSL certificate for Postgres remains valid.",
                      "defaultValue": "820"
                    },
                    "POSTGRES_PASSWORD": {
                      "isOptional": false,
                      "description": "Password assigned to the default PostgreSQL user.",
                      "defaultValue": "{{POSTGRES_PASSWORD}}"
                    },
                    "DATABASE_PUBLIC_URL": {
                      "isOptional": false,
                      "description": "Publicly accessible URL for the database",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_TCP_PROXY_DOMAIN}}:${{RAILWAY_TCP_PROXY_PORT}}/${{PGDATABASE}}"
                    },
                    "RAILWAY_DEPLOYMENT_DRAINING_SECONDS": {
                      "isOptional": false,
                      "description": "Grace period (in seconds) Railway gives before shutting down the container, allowing active connections to close cleanly.",
                      "defaultValue": "60"
                    }
                  },
                  "networking": {
                    "tcpProxies": {
                      "5432": {}
                    }
                  },
                  "volumeMounts": {
                    "cb9775ae-ccea-4dc7-80be-6232ab79abc7": {
                      "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."
                  }
                },
                "fbffe9f4-c2a5-4b4c-bdbb-19af7b887554": {
                  "icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/n8n.svg",
                  "name": "n8n",
                  "deploy": {
                    "startCommand": null,
                    "healthcheckPath": null
                  },
                  "source": {
                    "image": "n8nio/n8n"
                  },
                  "variables": {
                    "PORT": {
                      "isOptional": false,
                      "description": "The HTTP port on which n8n will run. Default is 5678. Change only if it conflicts with another service.",
                      "defaultValue": "5678"
                    },
                    "DB_TYPE": {
                      "isOptional": false,
                      "description": "Specifies the database type used by n8n, in this case postgres.",
                      "defaultValue": "postgresdb"
                    },
                    "N8N_PORT": {
                      "isOptional": false,
                      "description": "Port on which the n8n service runs inside the container.",
                      "defaultValue": "5678"
                    },
                    "WEBHOOK_URL": {
                      "isOptional": false,
                      "description": "Public URL used by n8n to handle incoming webhooks and triggers.",
                      "defaultValue": "https://${{RAILWAY_PUBLIC_DOMAIN}}"
                    },
                    "DB_POSTGRESDB_HOST": {
                      "isOptional": false,
                      "description": "Host address of the PostgreSQL database (auto-filled by Railway).",
                      "defaultValue": "${{Postgres.PGHOST}}"
                    },
                    "DB_POSTGRESDB_PORT": {
                      "isOptional": false,
                      "description": "Port number for connecting to the PostgreSQL database.",
                      "defaultValue": "${{Postgres.PGPORT}}"
                    },
                    "DB_POSTGRESDB_USER": {
                      "isOptional": false,
                      "description": "Username for authenticating with the PostgreSQL database.",
                      "defaultValue": "${{Postgres.POSTGRES_USER}}"
                    },
                    "EXECUTIONS_DATA_PRUNE": {
                      "isOptional": false,
                      "description": "Enables or disables automatic cleanup of old execution records.",
                      "defaultValue": "true"
                    },
                    "DB_POSTGRESDB_DATABASE": {
                      "isOptional": false,
                      "description": "Name of the PostgreSQL database where n8n stores workflows and execution data.",
                      "defaultValue": "${{Postgres.POSTGRES_DB}}"
                    },
                    "DB_POSTGRESDB_PASSWORD": {
                      "isOptional": false,
                      "description": "Password for the PostgreSQL user account.",
                      "defaultValue": "${{Postgres.POSTGRES_PASSWORD}}"
                    },
                    "N8N_DEFAULT_BINARY_DATA_MODE": {
                      "isOptional": false,
                      "description": "Sets how binary files (images, PDFs, etc.) are stored — in memory or filesystem.",
                      "defaultValue": "filesystem"
                    },
                    "EXECUTIONS_DATA_PRUNE_MAX_COUNT": {
                      "isOptional": false,
                      "description": "Defines the maximum number of execution records to retain when pruning.",
                      "defaultValue": "100"
                    },
                    "N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS": {
                      "isOptional": false,
                      "description": "When enabled, ensures n8n settings files have secure access permissions (for safety).",
                      "defaultValue": "true"
                    }
                  },
                  "networking": {
                    "serviceDomains": {
                      "<hasDomain>": {}
                    }
                  },
                  "volumeMounts": {
                    "fbffe9f4-c2a5-4b4c-bdbb-19af7b887554": {
                      "mountPath": "/data"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "post_deploy": {},
  "resources": {
    "expected_services": 2,
    "needs_volume": true
  },
  "generated_at": "2026-09-06T11:54:17.289Z",
  "generator_version": "0.1.0"
}
