How to Self-Host n8n on Render with PostgreSQL Persistence

Introduction:

Hey Dev.to community! đź‘‹
I’m Ayokunle, a full-stack developer passionate about low-code automation and AI-powered workflows. Recently, I’ve been exploring n8n, an incredible open-source automation tool, and decided to self-host …


This content originally appeared on DEV Community and was authored by ayothedoc3

Introduction:

Hey Dev.to community! đź‘‹

I’m Ayokunle, a full-stack developer passionate about low-code automation and AI-powered workflows. Recently, I’ve been exploring n8n, an incredible open-source automation tool, and decided to self-host it on Render with PostgreSQL for data persistence. In this tutorial, I’ll walk you through the entire process, step by step.

Whether you're new to n8n or looking for a reliable hosting solution, this guide will help you get started quickly. Let’s dive in!

What You’ll Learn:

  • How to set up a PostgreSQL database on Render.
  • How to deploy n8n as a self-hosted service on Render.
  • How to configure persistence using PostgreSQL.
  • Tips for troubleshooting and scaling your setup.

Prerequisites:

  1. A Render account (sign up at render.com).
  2. Basic knowledge of Docker and PostgreSQL.
  3. A GitHub repository for your n8n configuration (optional but recommended).

Step 1: Set Up a PostgreSQL Database on Render

  1. Log in to Render and go to the dashboard.
  2. Click New + and select PostgreSQL.
  3. Fill in the details:
    • Name: n8n-database (or any name you prefer).
    • Database: n8n (this will be the default database name).
    • User: n8n-user (or any username you prefer).
    • Region: Choose a region closest to you.
  4. Click Create Database.
  5. Once the database is created, note down the Connection String (you’ll need it later).

Step 2: Prepare Your n8n Configuration

  1. Create a GitHub Repository (optional but recommended):

    • Create a new repository (e.g., n8n-render).
    • Add a Dockerfile to the repository:
     FROM n8nio/n8n:latest
    
  • Add a render.yaml file for Render deployment:

     services:
       - type: web
         name: n8n
         runtime: docker
         env: docker
         plan: free
         envVars:
           - key: N8N_BASIC_AUTH_ACTIVE
             value: true
           - key: N8N_BASIC_AUTH_USER
             value: your-username
           - key: N8N_BASIC_AUTH_PASSWORD
             value: your-password
           - key: DB_TYPE
             value: postgresdb
           - key: DB_POSTGRESDB_DATABASE
             value: n8n
           - key: DB_POSTGRESDB_HOST
             value: your-postgres-host
           - key: DB_POSTGRESDB_PORT
             value: 5432
           - key: DB_POSTGRESDB_USER
             value: your-postgres-user
           - key: DB_POSTGRESDB_PASSWORD
             value: your-postgres-password
    

    Replace the placeholders (your-username, your-password, your-postgres-host, etc.) with your actual values.

Step 3: Deploy n8n to Render

  1. Connect Your GitHub Repository:
    • Go to the Render dashboard and click New + > Web Service.
    • Connect your GitHub account and select the repository you created.
  2. Configure the Web Service:
    • Name your service (e.g., n8n).
    • Select the Free Plan (or upgrade if needed).
    • Ensure the render.yaml file is detected and used for configuration.
  3. Deploy:
    • Click Create Web Service.
    • Render will build and deploy your n8n instance.

Step 4: Verify the Deployment

  1. Once the deployment is complete, Render will provide a URL for your n8n instance (e.g., https://n8n.onrender.com).
  2. Visit the URL and log in using the credentials you set in the N8N_BASIC_AUTH_USER and N8N_BASIC_AUTH_PASSWORD environment variables.

Step 5: Test Persistence with PostgreSQL

  1. Create a Workflow:
    • Log in to your n8n instance and create a simple workflow (e.g., a Slack notification or HTTP request).
  2. Restart the Service:
    • Go to the Render dashboard and restart your n8n service.
  3. Verify Data Persistence:
    • After the restart, check if your workflows and credentials are still intact. If everything is configured correctly, your data should persist.

Step 6: (Optional) Set Up a Custom Domain

  1. Go to your n8n service in the Render dashboard.
  2. Click Settings > Custom Domains.
  3. Add your custom domain and follow the instructions to configure DNS settings.

Troubleshooting Tips:

  • Database Connection Issues: Double-check your PostgreSQL connection string and environment variables.
  • Basic Auth Not Working: Ensure N8N_BASIC_AUTH_ACTIVE, N8N_BASIC_AUTH_USER, and N8N_BASIC_AUTH_PASSWORD are correctly set.
  • Workflows Not Persisting: Verify that the DB_TYPE and other database-related environment variables are correctly configured.

Example Environment Variables:

Here’s a summary of the key environment variables you’ll need:

Key Value
N8N_BASIC_AUTH_ACTIVE true
N8N_BASIC_AUTH_USER your-username
N8N_BASIC_AUTH_PASSWORD your-password
DB_TYPE postgresdb
DB_POSTGRESDB_DATABASE n8n
DB_POSTGRESDB_HOST your-postgres-host
DB_POSTGRESDB_PORT 5432
DB_POSTGRESDB_USER your-postgres-user
DB_POSTGRESDB_PASSWORD your-postgres-password

Conclusion:

You’ve successfully self-hosted n8n on Render and configured PostgreSQL for data persistence! This setup ensures that your workflows, credentials, and other data are saved even if your n8n instance restarts.

Call to Action:

  • Try building your own workflows and share your experience in the comments!
  • Check out my GitHub profile for more tutorials and projects.
  • Follow me on X (Twitter) for updates on low-code and AI automation.

Tags:

#n8n #render #postgresql #lowcode #automation #tutorial


This content originally appeared on DEV Community and was authored by ayothedoc3


Print Share Comment Cite Upload Translate Updates
APA

ayothedoc3 | Sciencx (2025-01-10T22:32:08+00:00) How to Self-Host n8n on Render with PostgreSQL Persistence. Retrieved from https://www.scien.cx/2025/01/10/how-to-self-host-n8n-on-render-with-postgresql-persistence/

MLA
" » How to Self-Host n8n on Render with PostgreSQL Persistence." ayothedoc3 | Sciencx - Friday January 10, 2025, https://www.scien.cx/2025/01/10/how-to-self-host-n8n-on-render-with-postgresql-persistence/
HARVARD
ayothedoc3 | Sciencx Friday January 10, 2025 » How to Self-Host n8n on Render with PostgreSQL Persistence., viewed ,<https://www.scien.cx/2025/01/10/how-to-self-host-n8n-on-render-with-postgresql-persistence/>
VANCOUVER
ayothedoc3 | Sciencx - » How to Self-Host n8n on Render with PostgreSQL Persistence. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/01/10/how-to-self-host-n8n-on-render-with-postgresql-persistence/
CHICAGO
" » How to Self-Host n8n on Render with PostgreSQL Persistence." ayothedoc3 | Sciencx - Accessed . https://www.scien.cx/2025/01/10/how-to-self-host-n8n-on-render-with-postgresql-persistence/
IEEE
" » How to Self-Host n8n on Render with PostgreSQL Persistence." ayothedoc3 | Sciencx [Online]. Available: https://www.scien.cx/2025/01/10/how-to-self-host-n8n-on-render-with-postgresql-persistence/. [Accessed: ]
rf:citation
» How to Self-Host n8n on Render with PostgreSQL Persistence | ayothedoc3 | Sciencx | https://www.scien.cx/2025/01/10/how-to-self-host-n8n-on-render-with-postgresql-persistence/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.