Loading repository dataβ¦
Loading repository dataβ¦
Shatat98 / repository
## π Repository: n8n-gcp-postgres-guide This guide helps you self-host **n8n** on a **Google Cloud VM** using **Docker + Docker Compose**, and migrate from default SQLite (filesystem) storage to **PostgreSQL** for improved performance and scalability.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
This guide helps you self-host n8n on a Google Cloud VM using Docker + Docker Compose, and migrate from default SQLite (filesystem) storage to PostgreSQL for improved performance and scalability.
Before you begin, make sure you have:
yourdomain.com)Compute Engine > VM instancesn8n-vme2-micro (Free Tier)β οΈ Go to your domain registrar and point an A record for your domain (e.g.,
ai.yourdomain.com) to the external IP of your VM.
SSH into your VM and run the following:
sudo apt update && sudo apt upgrade -y
sudo apt install docker.io docker-compose nginx certbot python3-certbot-nginx -y
sudo systemctl start docker
sudo systemctl enable docker
mkdir n8n-setup && cd n8n-setup
nano docker-compose.yml
Paste the following:
version: '3.7'
services:
postgres:
image: postgres:15
restart: always
environment:
POSTGRES_USER: n8n_user
POSTGRES_PASSWORD: YOUR_PASSWORD
POSTGRES_DB: n8n
volumes:
- postgres_data:/var/lib/postgresql/data
n8n:
image: n8nio/n8n
restart: unless-stopped
ports:
- 5678:5678
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n_user
- DB_POSTGRESDB_PASSWORD=YOUR_PASSWORD
- N8N_HOST=ai.yourdomain.com
- WEBHOOK_URL=https://ai.yourdomain.com/
- WEBHOOK_TUNNEL_URL=https://ai.yourdomain.com/
volumes:
- n8n_data:/home/node/.n8n
depends_on:
- postgres
volumes:
postgres_data:
n8n_data:
β οΈ Important: Replace all instances of:
YOUR_PASSWORDβ with a strong secure passwordai.yourdomain.comβ with your actual domain or subdomain
sudo docker-compose up -d
Check that both n8n and postgres containers are running:
sudo docker ps
sudo nano /etc/nginx/sites-available/n8n
Paste:
server {
server_name ai.yourdomain.com;
location / {
proxy_pass http://localhost:5678;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
β οΈ Make sure to replace
ai.yourdomain.comwith your actual domain
Enable it:
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Enable SSL:
sudo certbot --nginx -d ai.yourdomain.com
Visit: https://ai.yourdomain.com
You should see the n8n setup screen.
sudo docker exec -it CONTAINER_ID env | grep DB_
You should see values for:
DB_TYPE=postgresdb
DB_POSTGRESDB_HOST=postgres
...
sudo docker-compose down
sudo docker pull n8nio/n8n
sudo docker-compose up -d
Your data is kept in Docker volumes (n8n_data, postgres_data).
Always use strong passwords and avoid using defaults in production.
For A record setup: go to your domain registrar (e.g. GoDaddy, Namecheap) β DNS β add A record β point to VM's external IP.