Running automation workflows with n8n on a VPS is powerful, but accessing it via an IP address isn’t very user-friendly.
Imagine typing a long string of numbers every time you want to open your dashboard! By connecting a custom domain to your n8n instance, you gain a simple, professional, and secure URL, such as https://n8n.yourdomain.com.
This guide is for users who already have n8n running on their VPS using an IP address (e.g., http://IP:5678) and looking to access it via a custom domain with HTTPS.
Whether you are a beginner or an advanced user, this tutorial ensures you will understand each step clearly.
Let’s get started!
Steps to Set Up a Custom Domain for n8n on Your VPS
➢ Step 1: Point Your Domain to Your VPS
➔ Firstly, log in to your domain registrar’s control panel & Navigate to the DNS management section.
➔ Create an A Record for your subdomain.
For example:
Name |
Name |
Value |
A |
n8n.yourdomain.com |
<your-server-ip> |
➔ Save the changes and wait for the DNS propagation to complete. This can take anywhere from a few minutes to a few hours.
➢ Step 2: Install Nginx and Certbot
Nginx will act as a reverse proxy to forward traffic from your domain to n8n, while Certbot will help you enable HTTPS with Let’s Encrypt certificates.
➔ Connect to your VPS via SSH.
➔ Update your package list and install Nginx and Certbot:
| sudo apt update sudo apt install nginx certbot python3-certbot-nginx -y |
➔ Enable and start Nginx so it runs automatically on server boot:
| sudo systemctl enable nginx sudo systemctl start nginx |
➢ Step 3: Configure Nginx as a Reverse Proxy
Nginx will forward requests from your custom domain to the n8n service running on localhost:5678.
Create a new Nginx configuration file for n8n:
| sudo vi /etc/nginx/sites-available/n8n |
➔ You have to paste the following configuration:
server {
listen 80;
server_name n8n.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:5678;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}
|
➔ Save the file and exit the editor.
➔ Now, you have to enable the new configuration by creating a symbolic link:
| sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/ |
➔ Test the configuration for syntax errors:
| sudo nginx -t |
➔ Restart Nginx to apply the changes:
| sudo systemctl restart nginx |
At this point, your domain should forward traffic to your n8n instance, but it will still use HTTP.
➢ Step 4: Update n8n Container for Your Domain
Now comes the important part: telling your n8n setup to actually use your domain instead of localhost.
As right now, n8n is running… but it doesn’t know your domain name yet. We will fix that by restarting it with the right settings.
First, stop and remove your existing container:
|
docker stop n8n docker rm n8n |
Now, run n8n again with your domain details added:
|
docker run -d –name n8n \ -p 127.0.0.1:5678:5678 \ -v /root/n8n_data:/home/node/.n8n \ -e N8N_HOST=n8n.yourdomain.com \ -e N8N_PROTOCOL=https \ -e WEBHOOK_URL=https://n8n.yourdomain.com/ \ -e N8N_EDITOR_BASE_URL=https://n8n.yourdomain.com \ -e N8N_TRUST_PROXY=true \ -e N8N_SECURE_COOKIE=false \ –restart always \ n8nio/n8n:latest |
➢ Step 5: Enable HTTPS with Let’s Encrypt
➔ Now, you have to use Certbot to automatically obtain and configure an SSL certificate:
sudo certbot --nginx -d n8n.yourdomain.com |
That’s it! Your n8n dashboard is now accessible via your custom domain:
| https://n8n.yourdomain.com |
You now have a secure, easy-to-remember URL for accessing n8n, and your setup will automatically maintain HTTPS certificates. You can continue building automation workflows while maintaining a secure and professional instance.
Try our ready-to-go n8n self-hosting and start automating in minutes!
Quick Troubleshooting (If Something Feels Off)
Sometimes things don’t work perfectly on the first try.
It’s totally normal!
Here’s how to quickly spot and fix common issues:
-
➤ Seeing a 502 error?
This usually means n8n isn’t running properly. Just check if your container is up and running.
-
➤ Page not loading at all?
It is most likely a config issue. Double-check your Nginx setup. A small mistake there can block everything.
-
➤ Webhook not receiving any data?
Make sure your workflow is active in n8n. If it’s not active, it simply won’t listen.
★ Important Points to Remember
Basic Points
➔ Before anything else, make sure your domain is pointing to your server’s IP address. Otherwise, things won’t load (and you will just be staring at a blank page)
➔ Once you switch to your domain, forget the old habit of using IP:5678 — it’s no longer needed
➔ From now on, always access n8n using your domain with HTTPS: https://yourdomain
Most Necessary Points
After switching to your domain, there’s one small (but important) thing to take care of:
➔ After changing to the domain, you must: Go back to n8n and activate your workflow again. This refreshes everything with your new domain setup
➔ Always use the Production Webhook URL (/webhook) for real usage, as the Test URL (/webhook-test) is only for testing inside n8n & it won’t work once you go live with your domain.
Conclusion
And that’s it! Your n8n is no longer stuck behind an IP address.
You now have a clean, secure, and professional setup that’s easier to access and share, and ready for real-world automation. From setting up your domain to enabling HTTPS and fixing common issues, you’ve covered everything that actually matters.
Now, the only thing left?
Start building workflows and let n8n do the heavy lifting!
