Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Self-Host n8n on AWS EC2 with Docker - Install to First Login

Description and use

n8n and Postgres containers are up and running on an EC2 instance, with encrypted credentials and persistent storage, ready for first login and future hardening.

Problem

Deploy a self‑hosted n8n instance on an Amazon Linux 2023 EC2 instance without SaaS seat fees or execution caps, ensuring reproducible build and secure credential storage.

Outcome

n8n and Postgres containers are up and running on an EC2 instance, with encrypted credentials and persistent storage, ready for first login and future hardening.

Workflow

  • Launch an Amazon Linux 2023 EC2 instance (t3.small or larger) with a security group allowing SSH from your IP and optionally port 5678 from your IP.
  • SSH into the instance as ec2-user.
  • Install Docker engine: sudo dnf install -y docker and enable it: sudo systemctl enable --now docker.
  • Install Docker Compose v2 plugin: create /usr/local/lib/docker/cli-plugins, download the binary, make it executable, and verify with sudo docker compose version.
  • Clone the self‑host‑n8n‑on‑ec2 repo: git clone https://github.com/simplynadaf/self-host-n8n-on-ec2.git and cd self-host-n8n-on-ec2.
  • Edit compose/docker-compose.yml: set N8N_ENCRYPTION_KEY to a 32+ character random string, set DB_POSTGRESDB_PASSWORD and POSTGRES_PASSWORD to the same strong password, and optionally adjust other environment variables.
  • Run sudo docker compose up -d from the compose directory to pull images and start containers.
  • Verify service: `curl -s -o /dev/null -w 'n8n -> HTTP %{http_code} ' http://localhost:5678` should return HTTP 200.
  • Open http://<PUBLIC_IP>:5678 in a browser, complete the setup wizard to create the owner account.
  • (Optional) For production, stop publishing port 5678, use Caddy or another reverse proxy, move secrets to AWS Secrets Manager, and tighten the security group.
  • Record date: 2026-09-20T10:15:30.749Z