> ## Documentation Index
> Fetch the complete documentation index at: https://withseismic.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Self-Hosting n8n

> Deploy your own n8n instance with Railway - the fastest way to production

export const DealRedemption = ({title = "Special Offer", description = "Get exclusive access to this limited-time deal", code = "SAVE20", link = "#", validUntil, type = "offer", offerText = "Get Offer →"}) => {
  const [copied, setCopied] = React.useState(false);
  const isCodeType = type === "code";
  const handleCopy = async () => {
    if (!isCodeType) return;
    try {
      await navigator.clipboard.writeText(code);
      setCopied(true);
      setTimeout(() => setCopied(false), 2000);
    } catch (err) {
      console.error('Failed to copy:', err);
    }
  };
  const handleRedeem = () => {
    if (isCodeType) {
      handleCopy();
    }
    window.open(link, '_blank');
  };
  const handleGetOffer = () => {
    window.open(link, '_blank');
  };
  return <div className="card block font-normal group relative my-2 ring-2 ring-transparent rounded-2xl bg-white dark:bg-background-dark border border-gray-950/10 dark:border-white/10 overflow-hidden w-full">
      <div className="px-6 py-5 relative flex items-center justify-between">
        <div className="flex-1 pr-5">
          <h3 className="not-prose font-semibold text-base text-gray-800 dark:text-white m-0 mb-2">
            {title}
          </h3>
          <p className="prose font-normal text-sm leading-6 text-gray-600 dark:text-gray-400 mb-3">
            {description}
          </p>
          {validUntil && <p className="text-xs text-gray-500 dark:text-gray-500 italic">
              Valid until: {validUntil}
            </p>}
        </div>

        <div className="flex flex-col items-end justify-between min-w-[180px]">
          {isCodeType ? <>
              <div className="relative bg-orange-500 text-white px-6 py-4 rounded-lg text-center transition-all shadow-sm hover:shadow-md w-full mb-3 cursor-pointer group" onClick={handleCopy} title="Click to copy code">
                <div className="flex flex-col items-center gap-2">
                  <div className="text-base font-semibold tracking-wider">
                    {code}
                  </div>
                  <div className="text-xs text-white/80 opacity-0 group-hover:opacity-100 transition-opacity">
                    {copied ? 'Copied!' : 'Click to copy'}
                  </div>
                </div>
              </div>
              <button className="px-4 py-2 bg-white dark:bg-gray-700 text-orange-500 dark:text-orange-400 border-none rounded-md text-sm font-semibold cursor-pointer transition-all hover:bg-orange-50 dark:hover:bg-gray-600 hover:-translate-y-0.5" onClick={handleRedeem}>
                {offerText}
              </button>
            </> : <button className="px-6 py-3 bg-orange-500 hover:bg-orange-600 text-white border-none rounded-lg text-base font-semibold cursor-pointer transition-all hover:-translate-y-0.5 shadow-sm hover:shadow-md" onClick={handleGetOffer}>
              {offerText}
            </button>}
        </div>
      </div>
    </div>;
};

## What's the Fastest Way to Deploy n8n to Production?

<Info>
  Railway provides the quickest deployment path - one-click setup with Redis, PostgreSQL, and workers included, getting you production-ready in just 2 minutes.
</Info>

The fastest way to get n8n running in production is through Railway. It handles all the infrastructure complexity and gets you running in just 2 minutes.

<DealRedemption title="Deploy n8n on Railway" description="One-click deploy n8n with Redis, Postgres, and workers - production-ready in 2 minutes" link="https://railway.com/new/template/n8n-with-workers?referralCode=dougie" type="offer" offerText="Deploy Now →" />

## Why Should I Choose Railway for n8n Hosting?

<Info>
  Railway is recommended because it offers one-click deployment, automatic SSL, managed databases, auto-scaling, built-in monitoring, and easy updates - all without configuration.
</Info>

Railway is the recommended deployment method because it provides:

* **One-click deployment** - No configuration needed
* **Automatic SSL** - HTTPS out of the box
* **Managed databases** - PostgreSQL and Redis included
* **Auto-scaling** - Handles traffic spikes
* **Built-in monitoring** - See logs and metrics
* **Easy updates** - Redeploy with one click

## How Do I Set Up n8n on Railway?

<Info>
  You only need a GitHub account to get started. Railway handles the rest automatically through their template system.
</Info>

### Prerequisites

* Sign up for Railway at [railway.com](https://railway.com?referralCode=dougie)
* GitHub account for authentication

### Step-by-Step Deployment

1. **Click Deploy Button**
   * Use the deploy button above
   * Or visit [railway.com/new/template/n8n-with-workers](https://railway.com/new/template/n8n-with-workers?referralCode=dougie)

2. **Authorize Railway**
   * Sign in with GitHub
   * Authorize Railway to create repositories

3. **Deploy Template**
   * Click "Deploy" on the n8n template
   * Railway automatically provisions:
     * Redis for queues
     * PostgreSQL for data
     * n8n primary instance
     * n8n worker instances

4. **Access Your Instance**
   * Go to Railway dashboard
   * Click on "Primary" service
   * Navigate to Settings → Network
   * Click "Generate Domain"
   * Access your n8n at the provided URL

5. **Set Admin Credentials**
   * In Railway dashboard, go to Variables
   * Set these environment variables:
   ```
   N8N_BASIC_AUTH_ACTIVE=true
   N8N_BASIC_AUTH_USER=your_username
   N8N_BASIC_AUTH_PASSWORD=your_secure_password
   ```
   * Redeploy for changes to take effect

## What If I Want More Control Over My Deployment?

<Info>
  Docker Compose gives you full control over your n8n deployment with PostgreSQL and Redis, perfect for teams who want to manage their own infrastructure.
</Info>

If you prefer more control over your deployment, use Docker Compose:

```yaml theme={null}
version: '3.8'

services:
  postgres:
    image: postgres:15-alpine
    environment:
      POSTGRES_USER: n8n
      POSTGRES_PASSWORD: n8n
      POSTGRES_DB: n8n
    volumes:
      - postgres_data:/var/lib/postgresql/data

  redis:
    image: redis:7-alpine
    volumes:
      - redis_data:/data

  n8n:
    image: docker.n8n.io/n8nio/n8n
    ports:
      - "5678:5678"
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n
      - DB_POSTGRESDB_PASSWORD=n8n
      - QUEUE_BULL_REDIS_HOST=redis
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=changeme
    volumes:
      - n8n_data:/home/node/.n8n
    depends_on:
      - postgres
      - redis

volumes:
  n8n_data:
  postgres_data:
  redis_data:
```

Run with:

```bash theme={null}
docker-compose up -d
```

## What Should I Configure After Deployment?

<Info>
  After deployment, configure your webhook URL, enable execution pruning to keep your database clean, and set your timezone for accurate scheduling.
</Info>

### Configure Webhook URL

After deployment, configure your webhook URL:

1. In Railway or your deployment environment
2. Set the `WEBHOOK_URL` environment variable
3. Use your public domain: `https://your-domain.railway.app/`

### Enable Execution Pruning

Keep your database clean:

```
N8N_EXECUTIONS_DATA_PRUNE=true
N8N_EXECUTIONS_DATA_MAX_AGE=168
```

### Set Timezone

Configure your timezone:

```
GENERIC_TIMEZONE=America/New_York
```

## How Do I Monitor My n8n Instance?

<Info>
  Railway provides comprehensive monitoring with real-time logs, resource metrics, deployment tracking, and alerting capabilities built into the platform.
</Info>

### Railway Monitoring

Railway provides built-in monitoring:

* **Logs** - Real-time application logs
* **Metrics** - CPU, memory, and network usage
* **Deployments** - Track deployment history
* **Alerts** - Set up notifications

### Health Checks

Check if your instance is running:

```bash theme={null}
curl https://your-n8n-url.railway.app/healthz
```

## How Can I Scale My n8n Deployment?

<Info>
  Scale your n8n deployment by adding more worker replicas in Railway or optimizing your database connection pooling for better performance.
</Info>

### Adding More Workers

In Railway, scale workers by:

1. Go to your project settings
2. Find the n8n-worker service
3. Increase replica count
4. Railway handles load balancing

### Database Optimization

For better performance:

```
DB_POSTGRESDB_SSL_ENABLED=true
DATABASE_CONNECTION_POOL_MIN=2
DATABASE_CONNECTION_POOL_MAX=10
```

## What Are Common Issues and How Do I Fix Them?

<Info>
  Most issues relate to domain configuration, webhook URLs, memory usage, or authentication settings. Each has specific solutions and prevention strategies.
</Info>

### Common Issues

| Issue                      | Solution                                |
| -------------------------- | --------------------------------------- |
| Can't access n8n           | Check if domain is generated in Railway |
| Webhooks not working       | Ensure WEBHOOK\_URL is set correctly    |
| High memory usage          | Enable execution pruning                |
| Authentication not working | Check N8N\_BASIC\_AUTH variables        |

### Getting Help

* [n8n Community Forum](https://community.n8n.io)
* [Railway Discord](https://discord.gg/railway)
* [n8n Documentation](https://docs.n8n.io)

## What Should I Do After Setting Up Hosting?

<Info>
  After hosting setup, focus on configuring error handling, implementing retry strategies, and building advanced workflows to maximize your automation capabilities.
</Info>

* [Learn n8n Basics](/universities/automation/no-code/n8n-basics)
* [Explore Service Integrations](/universities/automation/no-code/n8n-service-integrations)
* [Discover LLM Workflow Generation](/universities/automation/no-code/n8n-llm-workflow-generation)

## Frequently Asked Questions

### How much does it cost to host n8n on Railway?

Railway offers a generous free tier that includes $5 of monthly usage. For production workloads, costs typically range from $10-50/month depending on your resource usage (CPU, memory, bandwidth). The exact cost depends on your workflow complexity and execution frequency.

### Can I migrate my data if I want to leave Railway?

Yes, you have full access to your PostgreSQL database and can export all your workflows, credentials, and execution history. n8n data is portable between hosting providers since you control the database.

### What happens if Railway has downtime?

Railway has excellent uptime (99.9%+), but for mission-critical applications, consider setting up monitoring and have a backup deployment ready. You can always restore your n8n instance on another provider using your database backups.

### How do I backup my n8n data on Railway?

Railway automatically backs up your PostgreSQL database. You can also set up additional backups by exporting workflows via the n8n API or CLI. Consider implementing automated backup workflows within n8n itself.

### Can I use my own domain with Railway?

Yes, Railway supports custom domains with automatic SSL certificates. Go to your service settings, add your domain, and update your DNS records as instructed. SSL certificates are managed automatically.

### How do I update my n8n version on Railway?

Railway automatically deploys the latest stable n8n version. You can also manually trigger deployments or pin to specific versions if needed. Updates are seamless with zero downtime.

### What's the difference between Railway and Docker Compose hosting?

Railway is fully managed (automatic updates, monitoring, scaling) while Docker Compose requires manual management but gives you complete control. Railway is better for teams wanting simplicity; Docker Compose for those needing customization.

### Can I connect Railway n8n to external databases?

Yes, you can configure n8n to use external PostgreSQL, MySQL, or other databases instead of Railway's managed database. This is useful for compliance or when integrating with existing infrastructure.

### How do I scale n8n for high-volume workflows?

On Railway, increase worker replicas and upgrade your database plan. For extreme scale, consider horizontal scaling with multiple n8n instances sharing the same database and Redis queue.

### What security features does Railway provide for n8n?

Railway provides automatic HTTPS, private networking between services, environment variable encryption, and infrastructure-level security. Always enable n8n's built-in authentication and consider additional access controls for production use.
