How to Set Up an Amazon EC2 Instance for Your Personal n8n Workspace
A complete step-by-step guide to installing, running, and securing n8n on an Amazon EC2 instance using Systemd and HTTPS.
Ashim Rudra Paul
Software Engineer

How to Set Up an Amazon EC2 Instance for Your Personal n8n Workspace
Prerequisites
Before we start, ensure you have:
- An AWS account and an EC2 instance launched (Amazon Linux 2 recommended).
- Basic familiarity with Linux commands and SSH.
- A public IP or domain name assigned to your EC2 instance.
Step 1: Update Your System
Start by ensuring your EC2 instance is up-to-date. Connect to your instance via SSH and run:
This command updates all installed packages, keeping your system secure and stable.
Step 2: Install Node.js and npm
n8n is built on Node.js, so install the Long-Term Support (LTS) version (Node.js 18.x at the time of writing):
Verify the installation:
You should see the versions of Node.js and npm displayed.
Step 3: Install n8n
With Node.js ready, install n8n globally using npm:
Confirm it is installed:
This should return the installed n8n version.
Step 4: Run n8n
To test n8n, start it with:
By default, n8n runs on port 5678. Open your browser and navigate to:
Replace <Instance_Public_IP> with your EC2 instance public IP.
Configure Security Group
For external access, go to your EC2 instance’s security group in the AWS Management Console and add an inbound rule:
- Type: Custom TCP
- Port Range: 5678
- Source:
0.0.0.0/0(or restrict to your IP for better security)
Save the rule and refresh your browser.
Step 5: Set Up n8n as a Background Service
Running n8n in the foreground is fine for testing, but for production, run it as a Systemd service.
Create a Service File
Create a new service file:
Add this content, replacing <your-user> with your Linux username (for example ec2-user on Amazon Linux):
Enable and Start the Service
Reload Systemd and start n8n:
Check status:
If it shows active (running), access n8n again at http://<Instance_Public_IP>:5678.
Step 6: Secure n8n with HTTPS
For stronger security, enable HTTPS using self-signed SSL certificates with OpenSSL.
Install OpenSSL and Generate Certificates
Install OpenSSL:
Create a directory for certificates:
Generate a self-signed certificate and key:
Verify files:
Set ownership to EC2 user:
Step 7: Update the Service for HTTPS
Modify the service file:
Replace with:
Replace:
<your_public_ip_address>with your EC2 public IP<your_username>with your preferred username<your_password>with a strong password
Restart the Service
Apply changes:
Now access n8n securely at:
Final Notes
Your personal n8n workspace is now running on EC2 with background process management and HTTPS enabled. For production-ready security, consider using a domain name with a trusted TLS certificate (for example Let’s Encrypt) and tighter security group rules.


