The plain HTTP request was sent to HTTPS port: error behind corporate proxy

Describe the problem/error/question

I’m running n8n via docker behind a corporate proxy which does not require authentication. I use the the following command to start n8n:

docker run -it --rm -d \
  --add-host=host.docker.internal:host-gateway \
  -e HTTP_PROXY=http://PROXY_IP:PORT \
  -e HTTPS_PROXY=http://PROXY_IP:PORT \
  -e NO_PROXY=localhost,127.0.0.1,host.docker.internal \
  -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
  -e N8N_RUNNERS_ENABLED=true \
  -e N8N_PROXY_HOPS=1 \
  -e WEBHOOK_URL=http://PROXY_IP:PORT \
  -v n8n_data:/home/node/.n8n \
  -v /home/user/n8n:/my-n8n-data \
  -p 5678:5678 \
  --name n8n \
  docker.n8n.io/n8nio/n8n

What is the error message (if any)?

The API calls to OpenAI fail and when I run a simple http_request I get the following error (The plain HTTP request was sent to HTTPS port):

Error code
400

Full message
400 - "<html>\r\n<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>\r\n<body>\r\n<center><h1>400 Bad Request</h1></center>\r\n<center>The plain HTTP request was sent to HTTPS port</center>\r\n</body>\r\n</html>\r\n"

Request
{ "headers": { "accept": "application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7" }, "method": "POST", "uri": "https://httpbin.org/ip", "gzip": true, "rejectUnauthorized": true, "followRedirect": true, "resolveWithFullResponse": true, "followAllRedirects": true, "proxy": "PROXY_IP:PORT", "timeout": 300000, "encoding": null, "json": false, "useStream": true }

Information on your n8n setup

  • **n8n version: [details=“instance information”]

Debug info

core

  • n8nVersion: 1.86.1
  • platform: docker (self-hosted)
  • nodeJsVersion: 20.19.0
  • database: sqlite
  • executionMode: regular
  • concurrency: -1
  • license: community
  • consumerId: unknown

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: memory

pruning

  • enabled: true
  • maxAge: 336 hours
  • maxCount: 10000 executions

client

  • userAgent: mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, like gecko) chrome/128.0.0.0 safari/537.36 edg/128.0.0.0
  • isTouchDevice: false

Generated at: 2025-04-10T17:08:18.586Z**
[/details]

  • Database (default: SQLite): default
  • Running n8n via: Docker version 28.0.4, build b8034c0
  • Operating system: Ubuntu 24.04.2

axios (which n8n uses for web requests) uses the HTTPS_PROXY and/or HTTP_PROXY env variables according to its readme.

According to this it might be worth checking to see if the PORT that you are setting in -e HTTP_PROXY=http://PROXY_IP:PORT is explicitly set to 80. If so, try leaving the port off and letting it use the default http port (which is still port 80) with just -e HTTP_PROXY=http://PROXY_IP

Thank you. I tried that and I got the following error:

{
  "errorMessage": "The service refused the connection - perhaps it is offline",
  "errorDetails": {
    "rawErrorMessage": [
      "connect ECONNREFUSED PROXY_IP:80",
      "connect ECONNREFUSED PROXY_IP:80"
    ],
    "httpCode": "ECONNREFUSED"
  },
  "n8nDetails": {
    "nodeName": "HTTP Request1",
    "nodeType": "n8n-nodes-base.httpRequest",
    "nodeVersion": 4.2,
    "itemIndex": 0,
    "time": "11/04/2025, 10:28:30",
    "n8nVersion": "1.86.1 (Self Hosted)",
    "binaryDataMode": "default",
    "stackTrace": [
      "NodeApiError: The service refused the connection - perhaps it is offline",
      "    at ExecuteContext.requestWithAuthentication (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/node-execution-context/utils/request-helper-functions.js:991:19)",
      "    at processTicksAndRejections (node:internal/process/task_queues:95:5)",
      "    at ExecuteContext.requestWithAuthentication (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/node-execution-context/utils/request-helper-functions.js:1147:20)"
    ]
  }
}

As an additional info, this happens with the OpenAI interface. I’m using for example a Google Mail component to send out some automated emails in my workflow and the connection to my Google API works fine.

Just to make sure: You did change PROXY_IP to the actual proxy IP :wink:

Of course :slight_smile: My company also uses a socks5 proxy which has solved some connectivity issues in other applications in the past, but I’m not sure if this is supported in n8n? It’s the same IP with a different port.

There is an open feature request for socks5 proxy support that mentions openai specifically. I didn’t see anything that would help you but it might be worth up-voting, and it might confirm your suspicions about what isn’t working.

Any solution? I’m facing exactly the same issue

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