(Skippable intro...)
My recent fixation has been automation. I started with Automate in hopes of never having to click a series of buttons before work (Graveyard shift and I'm a notorious napper). Although that was a complete flop, it unlocked a new algorithm character - one that eventually led to n8n popping up on my reddit feed.
Interesting. I was curious of the new tech despite my reluctance. Something about the "No Code" label bruised my programmer ego. Like a sneaky mouse, it also prowled its way up my Github feed. This time with a shiny, new reputation- open source.
I quickly grew fond of n8n after the first three nodes not because there's potential in profiting off of workflows, but of the fact that what would take days of wrestling with GPT and deep diving year-old posts on Stack can be done in a few hours, in a single sitting. There's absolutely no excuse for me to procrastinate the ideas I have to make my life easier.
The best part? You can use it for free!
Step by Step: Self-Hosting
Getting Started
I'm pretty sure there's other ways to do this but this one worked for me: AWS EC2 & Docker. So shoutout to Eric Tech. Most of the info you need will be there, but try to follow along the steps I have as well.
What you need to do
- Get an AWS EC2 account (Free tier).
- You will get $100 sign up credits and up to another $100 for completing onboarding tasks
- I use Ubuntu as the application/OS. Create a keypair, it'll be downloaded on your computer. Then click Launch instance
- SSH into the instance you created. Note: In the video he used Tabby, and I did try setting that up but couldn't for some reason
AWS EC2 changed their Free Tier policies. I was able to create an account before July 15, 2025 so I keep mine on a 12 month Free Trial. A crediting system was implemented in place of that. New accounts (Users who signed up after July 15, 2025) will get $100 sign up credits and up to another $100 for completing onboarding tasks.
Find out more here: Explore AWS services with AWS Free Tier
- Copy the public IPv4 address
- Open your terminal and type:
ssh -i your-key-pair.pem ubuntu@[ipv4_address]
- Once you've access to your instance, install Docker and Nginx
sudo apt update
sudo curl -fsSL https://get.docker.com | bash -s docker
sudo apt install nginx
Setting up your domain
In hindsight, I wish I'd set up the domain before everything else. I highly recommend you get one. Having one saves you from the headache I encountered when setting up Google Calendar credentials.
If you don't have a domain
I would simply follow Eric starting 6:08. You will need a tunnel (Ngrok or Cloudflare) for the redirect domain url. (Check this link for context).
I got my domain for free from Namecheap for Education, which I discovered through the Github Student Developer pack.
If you do have a domain
- Enable HTTPS with Certbot
- It's free and some features require it.
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d [yourdomain].tld -d www.[yourdomain].tld
It should let you know if it worked through a message similar to this:
Account registered. Requesting a certificate for [domain] and www.[domain].tld Successfully received certificate.
Successfully deployed certificate for [domain] to /etc/nginx/sites-enabled/default Congratulations!
You have successfully enabled HTTPS on https:[domain].tld and https://www.[domain].tld
/etc/nginx/sites-enabled/default is Nginx's default config file. We will go back to this file later.
Connect AWS EC2 Instance to Domain
To manage my domain I used Route 53, the AWS DNS Service. This is completely optional, which unfortunately, I only recently discovered. You'll pay $0.50/month per hosted zone (domain), but it gives you advanced routing options and integrates really well with your EC2 instance.
If you bought your domain from Namecheap, it has its own DNS service. Make sure the domain points to your app by following these steps:
- Login in to Namecheap and go to Domain List. Select manage which next to your domain.
- Use "Namecheap Basic DNS"
- In Namecheap's Advanced DNS tab, this is what you should have under Host Records
Type | Host | Value | TTL |
---|---|---|---|
A Record | @ | EC2 Instance public IPv4 address | Automatic |
A Record | www | @ | Automatic |
CNAME Record | www | [domain].tld | 30 min |
Create n8n instance on Docker
With the domain all set up we can now create a docker instance for n8n.
- While still ssh'ed into your ec2 instance, paste and replace the host and webhook_url variables with your domain name on the terminal
sudo docker run -d \
--name n8n \
-e N8N_HOST=[domainname].tld \
-e N8N_PORT=5678 \
-e WEBHOOK_URL=https://[domainname].tld \
-e N8N_SECURE_COOKIE=false \
-v n8n_data:/home/node/.n8n \
-p 5678:5678 \
n8nio/n8n
- Confirm the instance is running
sudo docker ps
EC2 Instance: Security Group
For it to be accessible, we must expose the endpoint. Follow Eric as he creates a new rule on 6:26.
Aside from those you will need to allow port 443 (default port for HTTPS) and port 80.
Type | Protocol | Port | Source |
---|---|---|---|
HTTP | TCP | 80 | 0.0.0.0/0 |
HTTPS | TCP | 443 | 0.0.0.0/0 |
Reverse Proxy using Nginx
The app is running on port 5678, which means your domain url will end on :5678. To avoid this, we can setup a reverse proxy on port 80. Nginx will be used to accept requests and internally forward them to the app on port 5678
- Edit the nginx config file
sudo nano /etc/nginx/sites-enabled/default
- Paste and edit this on terminal.
server {
listen 80;
server_name domain.tld www.domain.tld;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name domain.tld www.domain.tld;
ssl_certificate /etc/letsencrypt/live/[domain].tld/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/[domain].tld/privkey.pem;
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;
}
}
ssl_certificate /etc/letsencrypt/live/[domain].tld/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/[domain].tld/privkey.pem;
Is where the bot from earlier saved your ssl certificate
- Restart Nginx
sudo systemctl restart nginx
Wait a little bit for it to propagate. You can check if it has, through a DNS Checker
Conclusion
When all that's done, you should be able to access n8n live using your https://domain.tld
The last thing on your list after signing in is activating your free n8n license key which it will prompt you to do so. Then that's it you can create workflows and have them run 24/7!
! 500