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:
- A Render account (sign up at render.com).
- Basic knowledge of Docker and PostgreSQL.
- A GitHub repository for your n8n configuration (optional but recommended).
Step 1: Set Up a PostgreSQL Database on Render
- Log in to Render and go to the dashboard.
- Click New + and select PostgreSQL.
- 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.
-
Name:
- Click Create Database.
- Once the database is created, note down the Connection String (you’ll need it later).
Step 2: Prepare Your n8n Configuration
-
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
- Create a new repository (e.g.,
-
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
-
Connect Your GitHub Repository:
- Go to the Render dashboard and click New + > Web Service.
- Connect your GitHub account and select the repository you created.
-
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.
- Name your service (e.g.,
-
Deploy:
- Click Create Web Service.
- Render will build and deploy your n8n instance.
Step 4: Verify the Deployment
- Once the deployment is complete, Render will provide a URL for your n8n instance (e.g.,
https://n8n.onrender.com
). - Visit the URL and log in using the credentials you set in the
N8N_BASIC_AUTH_USER
andN8N_BASIC_AUTH_PASSWORD
environment variables.
Step 5: Test Persistence with PostgreSQL
-
Create a Workflow:
- Log in to your n8n instance and create a simple workflow (e.g., a Slack notification or HTTP request).
-
Restart the Service:
- Go to the Render dashboard and restart your n8n service.
-
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
- Go to your n8n service in the Render dashboard.
- Click Settings > Custom Domains.
- 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
, andN8N_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
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.