This repository provides a Docker Compose setup for running a self-hosted n8n instance with scaling capabilities.
- Works out of the box: Just configure the
.envfile and run the start script. - Scalable: Runs n8n in
queuemode with separate workers, ready for high loads. - Handles Large Files: Configured to save binary data to the filesystem, allowing workflows to process large files without memory issues.
- Ready-to-use Scripts: Includes simple scripts to start, restart, and update the application.
- Long-term History: Execution history is stored for 2 months.
- Secure: Uses the latest recommended security environment variables for n8n.
- Private: n8n telemetry is disabled by default.
- Full-featured: SMTP is pre-configured for password recovery and other email functions.
- Automatic HTTPS: Uses Caddy as a reverse proxy for automatic SSL certificates.
- Persistent Data: Data is stored in a PostgreSQL database.
- Caching: Uses Redis for caching.
- Docker and Docker Compose installed.
- A domain name pointed to your server's IP address.
- A
.envfile with the required environment variables.
-
Clone the repository:
git clone https://github.com/AiratTop/n8n-self-hosted cd n8n-self-hosted -
Create the shared network: This setup uses a shared network to easily connect to external databases. If you haven't already, create the network:
docker network create shared_network
-
Configure the environment: Open the
.envfile and update the variables with your own settings. You can use my Open Source password generator to create a strong password. -
Start the application:
./start-docker.sh
This will start all the services in detached mode and scale the
n8n-workerservice to 2 replicas. -
Restart the application:
./restart-docker.sh
-
Update the application:
./update-docker.sh
This will automatically create a database backup, pull the latest Docker images, and restart the application.
This project includes a script to back up the n8n database.
To create a backup, run:
./backup.shThis will create a compressed SQL dump of your PostgreSQL database in the local_files/backups/ directory. It is recommended to run this script regularly (e.g., using a cron job).
This n8n setup is part of a larger ecosystem of self-hosted services that can all run on the same shared_network. This allows n8n to securely connect to them using their container names as hostnames.
Check out these pre-configured services that work out-of-the-box with this n8n instance:
- postgresql-self-hosted: A simple and robust PostgreSQL setup.
- mysql-self-hosted: A self-hosted MySQL instance.
- clickhouse-self-hosted: High-performance columnar database for analytics.
- metabase-self-hosted: Self-hosted Metabase on Docker for business intelligence and analytics.
- qdrant-self-hosted: A vector database for AI applications.
- redis-self-hosted: A fast in-memory data store, often used as a cache or message broker.
- caddy-self-hosted: A modern, easy-to-use web server with automatic HTTPS.
- wordpress-self-hosted: Production-ready WordPress stack with MySQL, phpMyAdmin, and WP-CLI.
- n8n-self-hosted: Scalable n8n with workers, Caddy for auto-HTTPS, and backup scripts.
- monitoring-self-hosted: Self-hosted monitoring stack with Prometheus and Grafana.
- ollama-self-hosted: Ready-to-use solution for running Ollama with the Open WebUI on Docker.
- authentik-self-hosted: Authentik is a flexible, open-source Identity & Access Management (IAM) solution.
- gatus-self-hosted: Automated service health dashboard with a PostgreSQL backend and backup scripts.
- beszel-self-hosted: Ready-to-run Beszel hub + agent stack for monitoring your infrastructure.
caddy: Reverse proxyn8n-master: Main n8n instancen8n-worker: n8n worker instancesn8n-psql: PostgreSQL databasen8n-redis: Redis cache
This project is licensed under the MIT License - see the LICENSE file for details.
AiratTop
- Website: airat.top
- GitHub: @AiratTop
- Email: mail@airat.top
- Repository: n8n-self-hosted