I'm having a bit of trouble setting up **n8n** behind an **Nginx reverse proxy** with **SSL** on my **VPS**. The n8n container runs smoothly on port 5678 (I confirmed this with a curl request to http://127.0.0.1:5678), but Nginx just can't seem to connect to n8n. I'm seeing some error messages in the logs that are quite concerning:
1. **SSL Handshake Failed:** SSL_do_handshake() failed (SSL: error:0A00006C:SSL routines::bad key share)
2. **Connection Refused** and **Connection Reset:** connect() failed (111: Connection refused) while connecting to upstream
3. **No Live Upstreams:** no live upstreams while connecting to upstream
Here's what I've done so far to troubleshoot:
1. Verified that **n8n is running** and reachable on 127.0.0.1:5678.
2. Checked that the **SSL certificates are valid** (they're good until July 2025).
3. Looked through the Nginx config to ensure the proxy_pass is directed to the right address: proxy_pass http://127.0.0.1:5678.
4. Restarted both **Nginx** and **n8n** multiple times.
5. Made sure **Nginx is listening on port 443** and the **firewall rules** are set to allow traffic on ports 80 and 443.
Even after all these checks, I'm still stuck. Nginx can't connect to n8n, which definitely seems like an SSL or proxy issue. Has anyone else faced something similar or have any tips on where I might be going wrong?
3 Answers
Another point to consider is whether your SSL certificates are accessible from within the Nginx container. Make sure the paths are correct and that Nginx can read them. If issues persist, you might benefit from trying out nginx-proxy-manager for easier management.
It sounds like your Nginx configuration might be the culprit here. If Nginx is running in a container while n8n is also in one, using `localhost` won't work as intended. In that scenario, each container sees `localhost` as itself. You should point Nginx to n8n using '`http://host.docker.internal:5678`' or the service name, like '`http://n8n:5678`' if you're using Docker Compose.
Definitely try using the container name for your n8n service in the Nginx configuration if you haven't already. It's crucial that both Nginx and n8n are on the same Docker network. Also, check that your SSL certificate and key files are correctly set up in the Nginx container. You can access the container via `docker exec` and verify the files.
Related Questions
Cloudflare Origin SSL Certificate Setup Guide
How To Effectively Monetize A Site With Ads