HTTP Request Node Fails with "socket hang up" Behind Corporate Proxy (Windows, npm setup)

I’m currently running n8n v1.83.2 (Self-hosted) on Windows, installed via npm, and my server connects to the internet using a corporate proxy:

I’ve confirmed the proxy is working via curl

When I use the HTTP Request node in n8n (even a simple GET to https://api.ipify.org?format=json), I get the following error:

json

CopyEdit

{
  "errorMessage": "The connection to the server was closed unexpectedly, perhaps it is offline.",
  "errorDetails": {
    "rawErrorMessage": ["socket hang up", "socket hang up"],
    "httpCode": "ECONNRESET"
  }
}

What I’ve Tried:

Any advice from the community or dev team would be appreciated!

Hi @Abduh_Salam,

The “socket hang up” and ECONNRESET errors you’re seeing typically occur when there’s a network interruption or a proxy misconfiguration—especially behind a corporate proxy. Here’s a structured approach to troubleshoot and fix it:


Checklist to Resolve “socket hang up” Behind Corporate Proxy in n8n:

1. Confirm Proxy with Node.js

Since curl works, but n8n doesn’t, it’s likely a Node.js-specific issue. Test with plain Node.js:

const https = require('https');

https.get('https://api.ipify.org?format=json', (res) => {
  res.on('data', (d) => {
    process.stdout.write(d);
  });
}).on('error', (e) => {
  console.error(e);
});

Run with your proxy settings:

set HTTP_PROXY=http://corporate.co.id:8080
set HTTPS_PROXY=http://corporate.co.id:8080
node test.js

If this fails, the problem is your Node proxy config.


2. Use global-agent (If Not Already)

n8n uses Node under the hood, and the global-agent library can help route all HTTP/HTTPS traffic through the proxy.

Install if you haven’t:

npm install global-agent

Create a proxy-loader.js file with:

require('global-agent/bootstrap');

Then run n8n like this:

set GLOBAL_AGENT_HTTP_PROXY=http://corporate.co.id:8080
node -r ./proxy-loader.js node_modules/n8n/bin/n8n

3. Use Environment File Instead

Sometimes the set command doesn’t persist well. Try putting your env vars in a .env file:

HTTP_PROXY=http://corporate.co.id:8080
HTTPS_PROXY=http://corporate.co.id:8080
GLOBAL_AGENT_HTTP_PROXY=http://corporate.co.id:8080
NODE_TLS_REJECT_UNAUTHORIZED=0

Then use dotenv-cli to run:

npx dotenv -e .env -- n8n

4. Whitelist or Bypass Proxy for Localhost

Ensure your proxy settings don’t interfere with localhost:

set NO_PROXY=localhost,127.0.0.1

5. Windows-Specific: Use PowerShell Instead of CMD

Some proxy env vars behave differently depending on the shell. Try running the commands in PowerShell instead of CMD.


If this still doesn’t work, let me know:

  • Are you using NTLM auth proxy?
  • Do you require login credentials for the proxy?

Those cases may require something like node-ntlm-proxy-agent.

I hope this helps.

Hi thanks for your response

for point no 1 the Node.js confirmed connected to proxy
already tried point 2,3,4 still not working (socket hang up)
for point number 5, the proxy doesnt require credentials, tested by curl without credential and it work.
but in the other case i installed jenkins without credential the proxy not connected, when i try to add credential on the setting its work (FYI)
btw i already try also add credential for n8n and still not working.