Skip to content

tachafine/n8n-workflow

Repository files navigation

n8n Local Installation

This is a local installation of n8n, a workflow automation tool.

Prerequisites

  • Node.js (v20.17.0 or higher recommended)
  • npm

Installation

The installation has been completed. All dependencies are installed in the node_modules directory.

Running n8n

To start n8n, you can use one of the following methods:

Method 1: Using npm script (Recommended)

npm start

Method 2: Using npx directly

npx n8n

Method 3: Using the local binary

./node_modules/.bin/n8n

Accessing n8n

Once n8n is running, it will start a web interface. By default, you can access it at:

First Run

On the first run, n8n will:

  1. Create a user account (you'll be prompted to set up credentials)
  2. Store data in ~/.n8n by default

Configuration

n8n configuration can be customized through environment variables. Common settings include:

  • N8N_PORT - Change the port (default: 5678)
  • N8N_HOST - Change the host (default: localhost)
  • N8N_PROTOCOL - Set protocol (http or https)

Example:

N8N_PORT=3000 npm start

Data Storage

By default, n8n stores its data in ~/.n8n. To change this location, set the N8N_USER_FOLDER environment variable:

N8N_USER_FOLDER=/path/to/your/data npm start

Deploy to Railway

This project is configured for easy deployment to Railway via GitHub.

Prerequisites

  1. A Railway account (railway.app)
  2. GitHub account with this repository
  3. Railway CLI (optional): npm i -g @railway/cli

Deployment Steps

Option 1: Deploy via Railway Dashboard (Recommended)

  1. Push to GitHub:

    git add .
    git commit -m "Initial commit - n8n setup for Railway"
    git branch -M main
    git remote add origin <your-github-repo-url>
    git push -u origin main
  2. Connect Railway to GitHub:

    • Go to Railway.app and sign in
    • Click "New Project"
    • Select "Deploy from GitHub repo"
    • Choose your n8n repository
  3. Configure Environment Variables: In Railway dashboard, go to your service → Variables tab, and add:

    Required:

    • N8N_ENCRYPTION_KEY - Generate with: openssl rand -base64 32
    • N8N_HOST - Will be auto-set by Railway (format: your-app.up.railway.app)
    • N8N_PROTOCOL - Set to https
    • PORT - Railway sets this automatically (usually 443 or dynamic)

    Optional (Recommended for Production):

    • N8N_ENVIRONMENT=production
    • N8N_USER_MANAGEMENT_JWT_SECRET - Generate with: openssl rand -base64 32
  4. Add PostgreSQL (Recommended):

    • In Railway dashboard, click "+ New" → "Database" → "Add PostgreSQL"
    • Railway will automatically set DATABASE_URL environment variable
    • n8n will automatically use PostgreSQL if DATABASE_URL is set
  5. Deploy:

    • Railway will automatically detect the Node.js app
    • It will run npm install and npm start
    • Once deployed, Railway will provide a public URL
  6. Access Your n8n Instance:

    • Use the Railway-provided URL to access your n8n instance
    • Complete the initial setup to create your admin account

Option 2: Deploy via Railway CLI

# Install Railway CLI
npm i -g @railway/cli

# Login to Railway
railway login

# Initialize Railway project
railway init

# Link to existing project or create new one
railway link

# Set environment variables
railway variables set N8N_ENCRYPTION_KEY=$(openssl rand -base64 32)
railway variables set N8N_PROTOCOL=https
railway variables set N8N_ENVIRONMENT=production

# Deploy
railway up

Railway Configuration Files

This project includes:

  • railway.json - Railway configuration
  • nixpacks.toml - Build configuration
  • Procfile - Process definition
  • env.example - Example environment variables

Important Notes for Railway Deployment

  1. Port Configuration:

    • Railway automatically sets the PORT environment variable
    • n8n will use this port automatically
    • You don't need to set N8N_PORT manually
  2. Database:

    • For production, use Railway's PostgreSQL plugin
    • n8n automatically detects and uses DATABASE_URL if available
    • SQLite (default) works but is not recommended for production
  3. Encryption Key:

    • CRITICAL: Set a strong N8N_ENCRYPTION_KEY before first deployment
    • This key encrypts sensitive data in your workflows
    • Generate with: openssl rand -base64 32
    • Save this key securely - you'll need it for future deployments
  4. Webhooks:

    • Railway provides HTTPS URLs automatically
    • Your webhook URLs will be: https://your-app.up.railway.app/webhook/...
  5. Persistent Storage:

    • For production, use PostgreSQL for persistent data
    • Ephemeral file storage is lost on redeploy without PostgreSQL

Troubleshooting

  • Build fails: Ensure Node.js version is compatible (v20+)
  • App won't start: Check Railway logs for environment variable errors
  • Database connection issues: Verify DATABASE_URL is set correctly in Railway
  • Webhook URLs not working: Ensure N8N_HOST and N8N_PROTOCOL are set correctly

Additional Information

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors