ECONNREFUSED when trying to connect to my local API from n8n Docker

My phyton script works fine when I curl from my terminal

But when I use the HTTP Request Node in n8n to GET https://localhost:8000, it fails immediately

ERROR: connect ECONNREFUSED 127.0.01:8000

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:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

hello @Charlotte_Baker

Are you using n8n in Docker? The issue seems very standard for Docker, as you are not able to call anything on the host instance from within the Docker container.

You will need to use the special DNS entry for your host called host.docker.internal instead of the localhost
How-tos | Docker Docs