Description
I deployed n8n in an internal corporate network where all internet connections must go through a proxy . However, n8n fails to connect to the internet when using the corporate network, while it works fine when switching to a mobile network .
I have tried multiple deployment methods, including:
Docker container
npm installation (bare metal Ubuntu 22.04 server)
n8n desktop app
Regardless of the method, n8n cannot connect to external APIs via the proxy .
n8n setup Information
**n8n version:**1.79.3
**Database (default: SQLite):**SQLite
**n8n EXECUTIONS_PROCESS setting (default: own, main):**default
**Running n8n via (Docker, npm, n8n cloud, desktop app):**Docker, npm, desktop app
**Operating system:**Ubuntu 22.04 Server
Issue Details
I built a simple AI chatbot workflow that integrates with Azure OpenAI API . The API requests must go through the corporate proxy .
I have already set up the proxy correctly at multiple levels:
export HTTP_PROXY
/ HTTPS_PROXY
(both globally and per user)
Configured npm
& Node.js
to use the correct proxy
Modified .bashrc
, .npmrc
, /etc/environment
to persist settings
Tested with curl
, wget
â both work fine through the proxy
However, n8n fails to connect to the internet via the proxy , while other tools can.
Workflow Design
Error Logs
Error in handler N8nLlmTracing, handleLLMStart: TypeError: fetch failed
Connection error.
request to https://xxxapi.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=20xx-01-01-preview failed, reason: connect EHOSTUNREACH 20.xx.xx.xx:443
Steps Taken to Troubleshoot
Tested network connection from within the n8n environment:
curl
Works
wget
Works
Checked n8nâs proxy settings:
Configured .npmrc
, .bashrc
, /etc/environment
to persist proxy settings.
Tested HTTP Request Node in n8n
Manually added http://xx.xx.com:xxxx
under âProxyâ settings
Request still fails with EHOSTUNREACH
error.
Tried running n8n inside and outside Docker
Both npm
and Docker
deployments fail to use the proxy.
However, switching to mobile network immediately fixes the issue .
Expected Behavior
n8n should be able to make external API calls via the configured corporate proxy .
Other tools (curl
, wget
, npm
) can already do this without issues .
Actual Behavior
n8n cannot connect to external APIs (e.g., https://api.openai.com
) when behind the proxy .
Other applications in the same environment can connect just fine .
Additional Notes
This issue occurs regardless of whether I run n8n via npm , Docker , or desktop app .
Switching to a mobile network resolves the issue instantly , proving that the proxy is the root cause .
Thank You!
I appreciate any insights or fixes you can provide.
If thereâs any debug mode or additional logs you need, let me know!
Here are a few things to double-check and try:
Environment Variable Scope: Make absolutely sure the HTTP_PROXY
and HTTPS_PROXY
environment variables are being picked up by the n8n process itself. When starting n8n (especially via npm), set them directly in the terminal session before launching n8n. For Docker, ensure youâre passing them correctly in your docker run
or docker-compose.yml
.
HTTP Request Node Proxy Setting: In your workflow, try explicitly setting the âProxyâ field in the HTTP Request node to your proxy URL (e.g., http://your-proxy-host:port
). Test with a simple URL like https://httpbin.org/ip
to isolate the issue.
Proxy Authentication: Does your proxy require authentication? If so, make sure youâre including your username and password in the proxy URL (e.g., http://username:password@your-proxy-host:port
) in both environment variables and the HTTP Request node setting.
NODE_TLS_REJECT_UNAUTHORIZED=0
(Cautiously): While youâve tried this, only use it for testing if you suspect SSL issues with your proxy. Itâs not recommended for production.
If none of this works, double-check the n8n environment variable documentation to see if there are any other proxy-related settings.
Good luck! Let us know how it goes.
Did it work is some way?
Iâm facing the same issue
1 Like
Same problem here.
All troubleshooting done so far are pointing to Axios (the web client) is not aware of the âCONNECTâ command used by proxy as well as the busybox wget implementationâŚ
While many are moving to the Cloud, those who arenât typically have sensitive data and often have their internet access restricted through a proxy server.
Itâs surprising that n8n offers an on-premise version, claiming it helps âmeet security standardsâ, yet fails to consider a basic security principle.
2 Likes
Kent1
May 2, 2025, 2:22pm
5
Hello,
Does your proxy allow connexion to AI model ? From my company I can access with proxy âuserâ but not with proxy âserverâ⌠security reason.
Did you try with your company proxy to use http node and reach a HTTPS website like https://google.com ? For me the problem was that my proxy is an http proxy and n8n seems to not like http proxy to access https website.
Come back to me if you canât reach https website like google behind your proxy I have a solution (not easy if you are not technical)
I can reach other sites from busy box pod after setting proxy and no_proxy⌠But, I canât reach same url from http workflow component
For me the problem was that my proxy is an http proxy and n8n seems to not like http proxy to access https website.
This is clearly the problem weâre facing : when connecting to a https site through a http proxy, you need to use CONNECT to the proxy so itâll tunnel client traffic to https site. And n8n is not doing this step !
Iâve done some tcpdump on the docker interface on my server :
from stock deployment, wget is not using CONNECT
after installing wget v1.25 from apk (using http repositoriesâŚ) : wget is using CONNECT to reach https sites
Problem still present with n8n v1.90.2
Kent1
May 7, 2025, 12:39pm
9
Could you try this WF and tell me if itâs work ?
You could also see this post :
Thank @Jon .
In fact there is a redirection where an overwrite of HttpsProxyAgent is made by Agent in the âgetBeforeRedirectFnâ function so my proxy is not used anymore.
[image]
I managed this but I donât really like to âforkâ n8n, it could cause bigger issue in the future (like the one where are currently speaking) and event if I currently able to bypass this Iâm not sure I always could
Cannot find module âaxiosâ [line 1]
VMError
Looks like I need to rebuild docker image with this module and try it
1 Like
Same here.
I upgraded n8n to v1.91.2 => same problem.
I also tried to upgrade axios to v1.9.0 inside container => same problem.
Kent1
May 7, 2025, 4:19pm
12
Stange axios is a default module in n8n (use by http node).
const axios = require(âaxiosâ);
const { HttpsProxyAgent } = require(âhttps-proxy-agentâ);
async function call() {
const url = âhttps://google.fr â;
const agent = new HttpsProxyAgent(âYOUR PROXY HEREâ);
const res = await axios.get(url, { httpAgent:agent, httpsAgent:agent, proxy: false });
return res
}
result = await call();
The code above works for meâŚIâm currently in 1.90.1
Following my ENV vars (maybe it comes from the ENV var N8N_RUNNERS_ALLOW_PROTOTYPE_MUTATION
N8N_RUNNERS_GRANT_TOKEN: âxxxxxxxxxxxxxxâ,
N8N_RUNNERS_TASK_BROKER_URI: âhttp://127.0.0.1:5679 â,
N8N_RUNNERS_MAX_PAYLOAD: â1073741824â,
N8N_RUNNERS_MAX_CONCURRENCY: â10â,
PATH: â/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binâ,
HOME: â/home/nodeâ,
NODE_FUNCTION_ALLOW_BUILTIN: *,
NODE_FUNCTION_ALLOW_EXTERNAL: *,
N8N_RUNNERS_ALLOW_PROTOTYPE_MUTATION: âtrueâ,
N8N_VERSION: â1.90.1â,
NODE_PATH: â/usr/local/lib/node_modules/n8n/dist/node_modules:/usr/local/lib/node_modules/n8n/node_modules:/usr/local/lib/node_modules:/usr/local/node_modules:/usr/node_modules:/node_modulesâ
I am getting same error Cannot find module âaxiosâ [line 1] in 1.91.2
Here is my ENV (with fresh container) :
N8N_DIAGNOSTICS_ENABLED=false
HTTPS_PROXY=hxxp://: @proxy :8080
N8N_HOST=server
no_proxy=host.docker.internal
NODE_VERSION=20.19.0
HOSTNAME=09e6e2177c77
YARN_VERSION=1.22.22
SHLVL=1
HOME=/root
https_proxy_license_server=hxxp://: @proxy :8080
N8N_PORT=5678
N8N_SSL_CERT=/files/ssl/self-signed/certificate.crt
N8N_SECURE_COOKIE=true
https_proxy=hxxp://: @proxy :8080
http_proxy=hxxp://: @proxy :8080
NODE_ICU_DATA=/usr/local/lib/node_modules/full-icu
TERM=xterm
N8N_SSL_KEY=/files/ssl/self-signed/private.key
GENERIC_TIMEZONE=Europe/Paris
N8N_TEMPLATES_ENABLED=false
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SHELL=/bin/sh
N8N_VERSION_NOTIFICATIONS_ENABLED=false
N8N_RELEASE_TYPE=stable
N8N_LOG_LEVEL=debug
PWD=/home/node
WEBHOOK_URL=hxxps://server:5678/
HTTP_PROXY=hxxp://: @proxy :8080
N8N_PROTOCOL=https
NODE_ENV=production
N8N_VERSION=1.91.2
http replaced with hxxp because ânew users can only post 5 URLsâ
And here is the error details :
{
"errorMessage": "Cannot find module 'axios' [line 1]",
"errorDescription": "VMError",
"errorDetails": {},
"n8nDetails": {
"nodeName": "Code",
"nodeType": "n8n-nodes-base.code",
"nodeVersion": 2,
"n8nVersion": "1.91.2 (Self Hosted)",
"binaryDataMode": "default",
"stackTrace": [
"VMError: Cannot find module 'axios'",
" at Resolver.resolveFull (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/resolver.js:126:9)",
" at Resolver.resolve (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/resolver.js:121:15)",
" at resolve (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/nodevm.js:317:21)",
" at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/bridge.js:490:11)",
" at requireImpl (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/setup-node-sandbox.js:90:19)",
" at require (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/setup-node-sandbox.js:171:10)",
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:1:112",
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:18:2",
" at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/bridge.js:490:11)",
" at NodeVM.run (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/nodevm.js:497:23)"
]
}
}
And when using the HTTP Request
module :
Sorry, limited to 3 reply cause Iâm a new user So I edit this one as I canât reply to @Kent1 .
Hi @Kent1 ,
Here is the new error with the env var added :
{
"errorMessage": "Cannot read properties of undefined (reading 'href') [line 6]",
"errorDescription": "TypeError",
"errorDetails": {},
"n8nDetails": {
"nodeName": "Code",
"nodeType": "n8n-nodes-base.code",
"nodeVersion": 2,
"n8nVersion": "1.91.2 (Self Hosted)",
"binaryDataMode": "default",
"stackTrace": [
"TypeError: Cannot read properties of undefined (reading 'href')",
" at new HttpsProxyAgent (/usr/local/lib/node_modules/n8n/node_modules/https-proxy-agent/dist/index.js:67:71)",
" at ReadOnlyHandler.construct (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/bridge.js:503:11)",
" at call (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:6:17)",
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:10:16",
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:18:2",
" at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/bridge.js:490:11)",
" at NodeVM.run (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/nodevm.js:497:23)",
" at JavaScriptSandbox.runCodeAllItems (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox.js:73:39)",
" at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Code.node.js:155:31)",
" at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/workflow-execute.js:687:50)"
]
}
}
Kent1
May 8, 2025, 9:15am
16
Can you try to set this env var
NODE_FUNCTION_ALLOW_EXTERNAL=*
Hi @Kent1 ,
Here is the new error with the env var added :
{
"errorMessage": "Cannot read properties of undefined (reading 'href') [line 6]",
"errorDescription": "TypeError",
"errorDetails": {},
"n8nDetails": {
"nodeName": "Code",
"nodeType": "n8n-nodes-base.code",
"nodeVersion": 2,
"n8nVersion": "1.91.2 (Self Hosted)",
"binaryDataMode": "default",
"stackTrace": [
"TypeError: Cannot read properties of undefined (reading 'href')",
" at new HttpsProxyAgent (/usr/local/lib/node_modules/n8n/node_modules/https-proxy-agent/dist/index.js:67:71)",
" at ReadOnlyHandler.construct (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/bridge.js:503:11)",
" at call (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:6:17)",
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:10:16",
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:18:2",
" at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/bridge.js:490:11)",
" at NodeVM.run (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/nodevm.js:497:23)",
" at JavaScriptSandbox.runCodeAllItems (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox.js:73:39)",
" at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Code.node.js:155:31)",
" at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/workflow-execute.js:687:50)"
]
}
}
Hi @Kent1 ,
It works when the proxy URL is hardcoded !!
It seems like axios isnât picking up (or canât find) proxyâs env varâŚ
Kent1
May 11, 2025, 12:03pm
20
So you have the same problem as me
To solved it I build my dockerimage with Dockerfile I use sed command to add this piece of code in Node request-helper-functions.ts.js file.
First it check if I need to use proxy env (with a boolean) and if yes I use https-proxy-agent to set proxy var.
const no_proxy = process.env.no_proxy.split(',');
var use_proxy = true;
for (let i = 0; i < no_proxy.length; i++){
if (requestObject.uri.includes(no_proxy[i]) ) {
use_proxy = false;
}
}
if (use_proxy) {
const { HttpsProxyAgent } = require("https-proxy-agent");
const agent = new HttpsProxyAgent(process.env.http_proxy);
axiosConfig.httpAgent = agent;
axiosConfig.httpsAgent = agent;
axiosConfig.proxy = false;
}
1 Like