Tuesday, December 2, 2025

Fix 404 Errors on Hostinger VPS: Configure n8n with a Custom Domain

Mastering Custom Domain Configuration for N8N on Hostinger VPS: Beyond the 404 Error

When you invest in self-hosting N8N on a Hostinger VPS, you're making a strategic decision to own your automation infrastructure. Yet many organizations encounter a frustrating roadblock: the dreaded 404 error when attempting to access their N8N instance through a custom domain. This isn't a failure of the platform—it's a signal that critical configuration layers remain disconnected.

Understanding the Domain Configuration Challenge

The journey from a default server address to a branded, custom domain involves orchestrating multiple systems in concert. Your domain name, DNS settings, server configuration, and N8N's internal environment variables must all speak the same language. When they don't, you're left staring at a 404 page—a symptom of a mismatch somewhere in this chain.

Think of it this way: your domain is the front door to your automation engine, but if the locks, hinges, and internal routing don't align, visitors can't enter. The 404 error typically means your browser successfully reached your Hostinger VPS, but the server couldn't locate the N8N application at the path it expected.

The Complete Domain Setup Workflow

DNS Configuration: Your Foundation

Before touching a single configuration file, ensure your domain's DNS A record points directly to your VPS's IP address. This is non-negotiable. Without this foundational step, your domain name has no idea where to direct traffic. Verify this is complete before proceeding further—it's the most commonly overlooked prerequisite.

Environment Variable Alignment

The core issue behind most 404 errors lies in misaligned environment variables within your N8N configuration. Your setup requires three critical variables to work in harmony:

The N8N_HOST variable must match your custom domain exactly. If you've configured N8N_HOST=yourdomain.com but your DNS points elsewhere, or if there's a subdomain mismatch, N8N won't recognize incoming requests as legitimate.

The WEBHOOK_URL variable must also reflect your custom domain in HTTPS format: WEBHOOK_URL=https://yourdomain.com/ This ensures webhooks and external integrations can properly communicate with your instance.

The N8N_PROTOCOL should be set to https when using a custom domain with SSL encryption. Mixing protocols—attempting HTTP access to an HTTPS-configured instance—triggers 404 responses.

The Docker Compose Configuration

Access your Docker Compose configuration file and verify these environment variables are properly set:

nano .env

Update the domain entry (typically appearing as srvXXXXX.hstgr.cloud by default) and replace it with your custom domain. Then restart the service:

docker compose down
docker compose up -d

NGINX Proxy Configuration

If you're using NGINX as a reverse proxy—which Hostinger often recommends—your proxy configuration must correctly forward requests to N8N's internal port (typically 5678). Create or edit your NGINX site configuration:

sudo nano /etc/nginx/sites-available/n8n

Ensure your configuration includes proper proxy headers and points to the correct localhost port:

server {
    server_name yourdomain.com;
    location / {
        proxy_pass http://localhost:5678;
        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;
    }
}

Enable the configuration and restart NGINX:

sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo systemctl restart nginx

SSL Certificate Installation

A missing or misconfigured SSL certificate often manifests as 404 errors or security warnings. Install a valid certificate for your domain:

sudo certbot --nginx -d yourdomain.com

The Critical Verification Step

After implementing these configurations, allow DNS propagation time—typically 24-48 hours, though often faster. Then test your setup by accessing https://yourdomain.com in your browser. You should see the N8N interface without SSL warnings.

If you still encounter a 404 error, systematically verify each layer: confirm DNS resolution using command-line tools, check that your VPS firewall allows traffic on port 443 (HTTPS) and 80 (HTTP), and review your N8N logs for configuration errors.

Advanced Automation Strategies

While troubleshooting domain configuration, consider how this technical foundation enables broader automation strategies. Organizations successfully implementing comprehensive N8N automation frameworks often discover that proper domain setup is just the beginning of their operational transformation.

The ability to access your N8N instance through a custom domain opens possibilities for advanced workflow automation patterns that integrate seamlessly with your existing business systems. When your automation platform operates under your organization's domain, it becomes a natural extension of your digital infrastructure rather than an external tool.

For teams exploring alternatives to traditional automation platforms, N8N's flexible approach to workflow design provides the technical precision that complex business processes demand. Unlike rigid SaaS solutions, self-hosted N8N instances give you complete control over data flow, security protocols, and integration patterns.

The Broader Strategic Insight

This troubleshooting process reveals something important about self-hosted infrastructure: the gap between "installed" and "operational" requires meticulous attention to how systems communicate. Organizations moving toward self-hosted automation platforms must recognize that this level of configuration control—while powerful—demands technical rigor. The 404 error isn't a flaw; it's feedback that your infrastructure architecture needs alignment.

Consider implementing hyperautomation strategies that leverage your properly configured N8N instance as a central orchestration hub. When domain configuration is solid, you can focus on building sophisticated automation workflows that connect disparate business systems into cohesive operational processes.

For organizations evaluating workflow automation solutions, Zoho Flow offers an alternative approach that eliminates infrastructure management complexity while maintaining powerful integration capabilities. The choice between self-hosted and cloud-based automation often depends on your organization's technical resources and control requirements.

By methodically working through domain configuration, DNS settings, environment variables, and proxy setup, you transform a self-hosted N8N instance from a technical curiosity into a reliable, branded automation platform that reflects your organization's commitment to owning its operational infrastructure.

Why do I see a 404 when accessing my self-hosted n8n on a custom domain?

A 404 usually means the request reached your Hostinger VPS but the server couldn't find the n8n app at the expected path. Common causes: your DNS A record doesn't point to the VPS IP, NGINX reverse proxy isn't forwarding to the correct port (usually 5678), or n8n's environment variables (N8N_HOST, WEBHOOK_URL, N8N_PROTOCOL) don't match the custom domain and protocol. For comprehensive workflow automation solutions, consider exploring n8n's flexible AI workflow automation platform which offers both technical precision and drag-and-drop simplicity.

What DNS record do I need to set for my custom domain?

Create an A record for your domain (or subdomain) that points directly to your VPS public IP. Without this, traffic won't reach your server. After changing DNS, allow propagation (commonly up to 24–48 hours, often faster) and verify with dig or nslookup. Understanding DNS configuration fundamentals can help you troubleshoot domain-related issues more effectively.

Which n8n environment variables must I update for a custom domain?

Ensure these three match your custom domain and protocol:

• N8N_HOST should equal your domain (e.g., yourdomain.com).
• WEBHOOK_URL should use the full HTTPS URL (e.g., https://yourdomain.com/).
• N8N_PROTOCOL should be set to https when using SSL. When configuring complex automation workflows, comprehensive automation guides can provide valuable insights for business success.

How do I apply changes after editing my Docker Compose .env or n8n variables?

Edit the .env used by Docker Compose (nano .env), update the domain entries, then restart the stack with docker compose down and docker compose up -d. For single containers, use docker restart or docker compose restart. For teams managing multiple automation projects, Zoho Projects provides excellent project coordination capabilities alongside your technical workflows.

How should I configure NGINX as a reverse proxy for n8n?

Configure a server block for your domain that proxies requests to n8n's port (typically http://localhost:5678). Include the common proxy headers: Host, X-Real-IP, X-Forwarded-For, and X-Forwarded-Proto. Example: proxy_pass http://localhost:5678; 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; Then enable the site and restart nginx. For advanced server configuration techniques, explore modern web development approaches that complement your automation infrastructure.

Do I need an SSL certificate and how do I install it?

Yes—use HTTPS and set N8N_PROTOCOL=https. With NGINX you can get a Let's Encrypt certificate via certbot: sudo certbot --nginx -d yourdomain.com. Ensure the certificate is installed correctly and that nginx has been reloaded. Misconfigured SSL can lead to browser warnings or routing issues that appear like a 404. Understanding cybersecurity best practices helps ensure your automation infrastructure remains secure and accessible.

What firewall and port settings are required?

Allow inbound traffic on ports 80 (HTTP) and 443 (HTTPS) so nginx can handle requests and manage certificates. The n8n container typically listens on an internal port (5678); only nginx needs external access. Verify with sudo ufw status or ss -tlnp to confirm ports 80/443 are open. For comprehensive security guidance, consider reviewing security compliance frameworks that protect your automation infrastructure.

How can I troubleshoot if things still show a 404 after configuration?

Check each layer: confirm DNS resolution with dig +short yourdomain.com; verify nginx is serving and proxying (sudo systemctl status nginx and nginx error logs); ensure the n8n container is running and view logs (docker compose logs -f n8n or docker logs ); confirm env variables inside the container; verify firewall rules; and test curl -I https://yourdomain.com to inspect responses. When troubleshooting complex technical issues, AI-powered automation guides can provide systematic approaches to problem-solving.

Why are webhooks failing even though the n8n UI loads?

Webhooks require WEBHOOK_URL to be correct (including https and trailing slash if configured). If using Cloudflare or another proxy service, ensure the domain is set to DNS-only (gray cloud) because some proxying can interfere with webhook delivery or WebSocket connections. Also confirm firewall and nginx forward the X-Forwarded headers correctly. For webhook integration strategies, explore Zoho Flow's integration platform which excels at building and managing complex webhook workflows.

Can I host n8n on a subpath like https://yourdomain.com/n8n instead of the root?

n8n is typically served at the root. Serving it on a subpath requires careful reverse-proxy configuration (path rewriting) and may need additional n8n options. If you must use a subpath, configure nginx to rewrite the location to the internal root and test webhooks thoroughly—root hosting at the domain or a dedicated subdomain is simpler and more reliable. For alternative automation approaches, consider Make.com's visual automation platform which offers flexible deployment options for various hosting scenarios.

How long does DNS propagation take and how can I verify propagation?

Propagation typically completes within 24–48 hours but often is much faster. Verify with dig +short yourdomain.com, nslookup, or online DNS checkers. If you see your VPS IP returned consistently from multiple locations, DNS has propagated. Understanding DNS mechanics is crucial for reliable automation deployments—cloud architecture fundamentals provide deeper insights into infrastructure reliability.

Any common pitfalls to watch for when moving from the default Hostinger address to a custom domain?

Common mistakes: forgetting to update N8N_HOST/WEBHOOK_URL/N8N_PROTOCOL, leaving the Docker .env with the default srvXXXXX.hstgr.cloud value, not enabling nginx site or restarting it, missing SSL configuration, firewall blocking ports 80/443, and using an HTTP protocol when n8n expects HTTPS. Verify each layer methodically to resolve these issues. For systematic troubleshooting approaches, hyperautomation strategies can help you build more resilient automation infrastructures.

No comments:

Post a Comment

Self-host n8n: Cut SaaS Fees, Own Your Data, and Scale Automations

Why Self-Hosting n8n Changes the Automation Game for Business Leaders Imagine reclaiming full control over your workflow automation withou...