{
  "manifest_version": "1.0.0",
  "template": {
    "id": "83eeb2f3-dee7-465c-a01b-d9e3d263819f",
    "slug": "n8n-postgres",
    "name": "N8N-Postgres",
    "description": "Production-ready n8n with an internal PostgreSQL database for persistence.",
    "url": "https://railway.com/deploy/n8n-postgres",
    "upstream": {
      "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
    }
  },
  "services": [
    {
      "name": "n8n-db",
      "source": {
        "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
      },
      "needs_volume": true,
      "volume_mount_path": "/var/lib/postgresql/data",
      "http": true
    },
    {
      "name": "n8n",
      "source": {
        "repo": "https://github.com/statin26/n8n-postgres-universal"
      },
      "needs_volume": false,
      "http": true
    }
  ],
  "required_inputs": [
    {
      "key": "PGDATA",
      "service": "n8n-db",
      "description": "Location where PostgreSQL stores its data files inside the container.",
      "secret": false,
      "strategy": "default",
      "default": "/var/lib/postgresql/data/pgdata"
    },
    {
      "key": "PGHOST",
      "service": "n8n-db",
      "description": "The network address or hostname used to connect to the PostgreSQL database.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "PGPORT",
      "service": "n8n-db",
      "description": "The port number the PostgreSQL database listens on (usually 5432).",
      "secret": false,
      "strategy": "default",
      "default": "5432"
    },
    {
      "key": "PGUSER",
      "service": "n8n-db",
      "description": "The default PostgreSQL username used to connect to the database.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGDATABASE",
      "service": "n8n-db",
      "description": "The primary database name your applications will connect to (dynamically links to POSTGRES_DB).",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGPASSWORD",
      "service": "n8n-db",
      "description": "The database password used for authentication (dynamically links to POSTGRES_PASSWORD).",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "POSTGRES_DB",
      "service": "n8n-db",
      "description": "The name of the default database created on startup.",
      "secret": false,
      "strategy": "default",
      "default": "railway"
    },
    {
      "key": "DATABASE_URL",
      "service": "n8n-db",
      "description": "The private connection string used by other services inside your Railway project to talk to the database securely.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "POSTGRES_USER",
      "service": "n8n-db",
      "description": "The master username for superuser access to the database.",
      "secret": false,
      "strategy": "default",
      "default": "postgres"
    },
    {
      "key": "SSL_CERT_DAYS",
      "service": "n8n-db",
      "description": "The number of days before the generated SSL certificate expires.",
      "secret": false,
      "strategy": "default",
      "default": "820"
    },
    {
      "key": "POSTGRES_PASSWORD",
      "service": "n8n-db",
      "description": "A securely generated, 32-character random password for the database.",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "DATABASE_PUBLIC_URL",
      "service": "n8n-db",
      "description": "The public connection string used to connect to your database from outside Railway (like your local machine or external tools).",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "RAILWAY_DEPLOYMENT_DRAINING_SECONDS",
      "service": "n8n-db",
      "description": "Time allowed for existing connections to finish before an old deployment shuts down.",
      "secret": false,
      "strategy": "default",
      "default": "60"
    },
    {
      "key": "PORT",
      "service": "n8n",
      "description": "The internal web server port that Railway routes traffic to (typically 5678).",
      "secret": false,
      "strategy": "default",
      "default": "5678"
    },
    {
      "key": "DB_TYPE",
      "service": "n8n",
      "description": "Specifies the type of database backend being used (set to postgresdb).",
      "secret": false,
      "strategy": "default",
      "default": "postgresdb"
    },
    {
      "key": "N8N_PORT",
      "service": "n8n",
      "description": "Tells n8n which port to bind to (should match the PORT variable).",
      "secret": false,
      "strategy": "default",
      "default": "5678"
    },
    {
      "key": "WEBHOOK_URL",
      "service": "n8n",
      "description": "The primary domain address n8n uses to receive external webhook triggers.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "N8N_PROTOCOL",
      "service": "n8n",
      "description": "Defines how clients connect to n8n (usually http or https).",
      "secret": false,
      "strategy": "default",
      "default": "https"
    },
    {
      "key": "DB_POSTGRESDB_HOST",
      "service": "n8n",
      "description": "The specific database name within PostgreSQL assigned to n8n.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DB_POSTGRESDB_PORT",
      "service": "n8n",
      "description": "The network port used to connect to your database (typically 5432).",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DB_POSTGRESDB_USER",
      "service": "n8n",
      "description": "The username n8n uses to log into your PostgreSQL database.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "N8N_ENCRYPTION_KEY",
      "service": "n8n",
      "description": "A secure, randomly generated key used to encrypt credentials stored in the database.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    },
    {
      "key": "EXECUTIONS_DATA_PRUNE",
      "service": "n8n",
      "description": "Set to true to automatically delete old workflow execution history to save database space.",
      "secret": false,
      "strategy": "default",
      "default": "true"
    },
    {
      "key": "DB_POSTGRESDB_DATABASE",
      "service": "n8n",
      "description": "The specific database name within PostgreSQL assigned to n8n.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "DB_POSTGRESDB_PASSWORD",
      "service": "n8n",
      "description": "The password n8n uses to authenticate with your PostgreSQL database.",
      "secret": true,
      "strategy": "default",
      "default": "GxrZrOXGArJWOQEEPxzrYYSPueXyBgdd"
    },
    {
      "key": "EXECUTIONS_DATA_MAX_AGE",
      "service": "n8n",
      "description": "The number of hours to keep workflow execution data before it gets pruned (e.g., 168 for 7 days).",
      "secret": false,
      "strategy": "default",
      "default": "168"
    },
    {
      "key": "N8N_DIAGNOSTICS_ENABLED",
      "service": "n8n",
      "description": "Set to false to disable sending anonymous telemetry data to n8n.",
      "secret": false,
      "strategy": "default",
      "default": "false"
    }
  ],
  "deploy": {
    "mcp": {
      "server": "railway",
      "tool": "deploy_template",
      "args": {
        "template_code": "n8n-postgres"
      }
    },
    "cli": "railway deploy --template n8n-postgres",
    "api": {
      "method": "POST",
      "path": "/graphql/v2",
      "body": {
        "query": "mutation templateDeploy($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }",
        "variables": {
          "input": {
            "templateId": "83eeb2f3-dee7-465c-a01b-d9e3d263819f",
            "serializedConfig": {
              "buckets": {},
              "services": {
                "55496f7d-3706-4b75-bdad-074d1cae97e8": {
                  "icon": "https://devicons.railway.app/i/postgresql.svg",
                  "name": "n8n-db",
                  "deploy": {
                    "startCommand": "n8n start",
                    "healthcheckPath": "/healthz",
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
                  },
                  "variables": {
                    "PGDATA": {
                      "isOptional": false,
                      "description": "Location where PostgreSQL stores its data files inside the container.",
                      "defaultValue": "/var/lib/postgresql/data/pgdata"
                    },
                    "PGHOST": {
                      "isOptional": false,
                      "description": "The network address or hostname used to connect to the PostgreSQL database.",
                      "defaultValue": "${{RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "PGPORT": {
                      "isOptional": false,
                      "description": "The port number the PostgreSQL database listens on (usually 5432).",
                      "defaultValue": "5432"
                    },
                    "PGUSER": {
                      "isOptional": false,
                      "description": "The default PostgreSQL username used to connect to the database.",
                      "defaultValue": "${{POSTGRES_USER}}"
                    },
                    "PGDATABASE": {
                      "isOptional": false,
                      "description": "The primary database name your applications will connect to (dynamically links to POSTGRES_DB).",
                      "defaultValue": "${{POSTGRES_DB}}"
                    },
                    "PGPASSWORD": {
                      "isOptional": false,
                      "description": "The database password used for authentication (dynamically links to POSTGRES_PASSWORD).",
                      "defaultValue": "${{POSTGRES_PASSWORD}}"
                    },
                    "POSTGRES_DB": {
                      "isOptional": false,
                      "description": "The name of the default database created on startup.",
                      "defaultValue": "railway"
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "The private connection string used by other services inside your Railway project to talk to the database securely.",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/${{PGDATABASE}}"
                    },
                    "POSTGRES_USER": {
                      "isOptional": false,
                      "description": "The master username for superuser access to the database.",
                      "defaultValue": "postgres"
                    },
                    "SSL_CERT_DAYS": {
                      "isOptional": false,
                      "description": "The number of days before the generated SSL certificate expires.",
                      "defaultValue": "820"
                    },
                    "POSTGRES_PASSWORD": {
                      "isOptional": false,
                      "description": "A securely generated, 32-character random password for the database.",
                      "defaultValue": "{{POSTGRES_PASSWORD}}"
                    },
                    "DATABASE_PUBLIC_URL": {
                      "isOptional": false,
                      "description": "The public connection string used to connect to your database from outside Railway (like your local machine or external tools).",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_TCP_PROXY_DOMAIN}}:${{RAILWAY_TCP_PROXY_PORT}}/${{PGDATABASE}}"
                    },
                    "RAILWAY_DEPLOYMENT_DRAINING_SECONDS": {
                      "isOptional": false,
                      "description": "Time allowed for existing connections to finish before an old deployment shuts down.",
                      "defaultValue": "60"
                    }
                  },
                  "networking": {
                    "serviceDomains": {
                      "<hasDomain>": {}
                    }
                  },
                  "volumeMounts": {
                    "55496f7d-3706-4b75-bdad-074d1cae97e8": {
                      "mountPath": "/var/lib/postgresql/data",
                      "backupSchedules": [
                        "WEEKLY"
                      ]
                    }
                  },
                  "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."
                  }
                },
                "e65473ea-2dc2-4ad9-b399-34796e935340": {
                  "icon": "https://upload.wikimedia.org/wikipedia/commons/5/53/N8n-logo-new.svg",
                  "name": "n8n",
                  "deploy": {
                    "startCommand": "n8n start",
                    "healthcheckPath": "/healthz",
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "repo": "https://github.com/statin26/n8n-postgres-universal",
                    "rootDirectory": "/"
                  },
                  "variables": {
                    "PORT": {
                      "isOptional": false,
                      "description": "The internal web server port that Railway routes traffic to (typically 5678).",
                      "defaultValue": "5678"
                    },
                    "DB_TYPE": {
                      "isOptional": false,
                      "description": "Specifies the type of database backend being used (set to postgresdb).",
                      "defaultValue": "postgresdb"
                    },
                    "N8N_PORT": {
                      "isOptional": false,
                      "description": "Tells n8n which port to bind to (should match the PORT variable).",
                      "defaultValue": "5678"
                    },
                    "WEBHOOK_URL": {
                      "isOptional": false,
                      "description": "The primary domain address n8n uses to receive external webhook triggers.",
                      "defaultValue": "${{n8n.RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "N8N_PROTOCOL": {
                      "isOptional": false,
                      "description": "Defines how clients connect to n8n (usually http or https).",
                      "defaultValue": "https"
                    },
                    "DB_POSTGRESDB_HOST": {
                      "isOptional": false,
                      "description": "The specific database name within PostgreSQL assigned to n8n.",
                      "defaultValue": "${{n8n-db.RAILWAY_TCP_PROXY_DOMAIN}}"
                    },
                    "DB_POSTGRESDB_PORT": {
                      "isOptional": false,
                      "description": "The network port used to connect to your database (typically 5432).",
                      "defaultValue": "${{n8n-db.RAILWAY_TCP_PROXY_PORT}}"
                    },
                    "DB_POSTGRESDB_USER": {
                      "isOptional": false,
                      "description": "The username n8n uses to log into your PostgreSQL database.",
                      "defaultValue": "${{n8n-db.POSTGRES_USER}}"
                    },
                    "N8N_ENCRYPTION_KEY": {
                      "isOptional": false,
                      "description": "A secure, randomly generated key used to encrypt credentials stored in the database.",
                      "defaultValue": "{{N8N_ENCRYPTION_KEY}}"
                    },
                    "EXECUTIONS_DATA_PRUNE": {
                      "isOptional": false,
                      "description": "Set to true to automatically delete old workflow execution history to save database space.",
                      "defaultValue": "true"
                    },
                    "DB_POSTGRESDB_DATABASE": {
                      "isOptional": false,
                      "description": "The specific database name within PostgreSQL assigned to n8n.",
                      "defaultValue": "${{n8n-db.POSTGRES_DB}}"
                    },
                    "DB_POSTGRESDB_PASSWORD": {
                      "isOptional": false,
                      "description": "The password n8n uses to authenticate with your PostgreSQL database.",
                      "defaultValue": "GxrZrOXGArJWOQEEPxzrYYSPueXyBgdd"
                    },
                    "EXECUTIONS_DATA_MAX_AGE": {
                      "isOptional": false,
                      "description": "The number of hours to keep workflow execution data before it gets pruned (e.g., 168 for 7 days).",
                      "defaultValue": "168"
                    },
                    "N8N_DIAGNOSTICS_ENABLED": {
                      "isOptional": false,
                      "description": "Set to false to disable sending anonymous telemetry data to n8n.",
                      "defaultValue": "false"
                    }
                  },
                  "networking": {
                    "serviceDomains": {
                      "<hasDomain>": {}
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "post_deploy": {
    "healthcheck": {
      "service": "n8n-db",
      "method": "GET",
      "path": "/healthz",
      "expect_status": 200
    }
  },
  "resources": {
    "expected_services": 2,
    "needs_volume": true
  },
  "generated_at": "2026-09-20T16:14:49.616Z",
  "generator_version": "0.1.0",
  "status": "degraded",
  "validated_at": "2026-09-20T11:20:17.979Z",
  "success_rate_30d": 0,
  "validation": {
    "last_run_id": "run_a60d135006a1468083aa",
    "checks": [
      {
        "name": "workflow_completed",
        "passed": true
      },
      {
        "name": "all_services_deployed",
        "passed": false,
        "detail": "FAILED,DEPLOYING"
      }
    ]
  }
}
