I'm getting ECONNRESET with AI node behind a reverse proxy

Describe the problem/error/question

I’m running the latest version of n8n from a docker container behind an nginx reverse proxy. The AI nodes are failing to get completions from both openAI and groq.

I’m assuming this is a problem with my hosting config (but I’ve run openAI nodes like this before and never had a problem)

What is the error message (if any)?

I also reproduced in the plain http node (the error appears to be the same). Details:

Node type

n8n-nodes-base.httpRequest

Node version

4.2 (Latest)

n8n version

1.55.3 (Self Hosted)

Time

26/08/2024, 16:09:24

Stack trace

NodeApiError: The connection to the server was closed unexpectedly, perhaps it is offline. You can retry the request immediately or wait and retry later. at Object.requestWithAuthentication (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/NodeExecuteFunctions.js:1296:19) at processTicksAndRejections (node:internal/process/task_queues:95:5) at Object.requestWithAuthentication (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/NodeExecuteFunctions.js:2087:20)

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.55.3 (Self Hosted)
  • Database (default: SQLite): PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): podman behind native nginx proxy (other nodes are working fine)
  • Operating system: NixOS

I just set up another n8n on coolify and I can confirm that the same workflow is working fine there.

Any ideas how to track down what might be up with my config? This is the relevant bit in my nginx config:

server {
		listen 0.0.0.0:443 ssl ;
		listen [::0]:443 ssl ;
		server_name XXX ;
		http2 on;
		ssl_certificate XXX/fullchain.pem;
		ssl_certificate_key XXX/key.pem;
		ssl_trusted_certificate XXX/chain.pem;
		location ^~ /.well-known/acme-challenge/ {
			root /var/lib/acme/acme-challenge;
			auth_basic off;
			auth_request off;
		}
		location / {
			proxy_pass http://127.0.0.1:5678;
			proxy_http_version 1.1;
			proxy_set_header Upgrade $http_upgrade;
			proxy_set_header Connection $connection_upgrade;
			include /nix/store/pylwan3mww2y56878wl1vfaaqjqkigpj-nginx-recommended-proxy-headers.conf;
		}
	}
# cat /nix/store/pylwan3mww2y56878wl1vfaaqjqkigpj-nginx-recommended-proxy-headers.conf
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_set_header        X-Forwarded-Host $host;
proxy_set_header        X-Forwarded-Server $host;

Hey @Ben_Ford,

This is an odd one, nginx as a reverse proxy should only impact inbound traffic not outbound.

As it is happening with the HTTP Node as well does it fail for other hosts or only the OpenAI / Groq ones?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.