Contents
The Short Answer
connect ECONNREFUSED means n8n opened a connection to an address and port, and the machine at that address actively refused it because nothing is listening there. The n8n HTTP Request documentation is precise about it: the node reaches a host on the network but the target port has no listener. It is not a DNS failure, a timeout, or a firewall drop.
The address in the error tells you where to look:
| Error ends with | Most likely cause | Use this instead |
|---|---|---|
127.0.0.1:<port> and n8n runs in Docker | localhost is the n8n container | http://host.docker.internal:<port> or the other container's service name |
::1:<port> | localhost resolved to IPv6 | http://127.0.0.1:<port> |
| A container or host name with a port | Wrong port, or the service is not running | The container's internal port, after confirming the service is up |
| Anything local, on n8n Cloud | Cloud cannot reach your machine | A public URL through a tunnel |
What the Error Is Telling You
ECONNREFUSED is an operating system error code that Node.js passes up to n8n. n8n keeps a list of friendly messages for common codes and shows the matching one as the error title, with the raw text underneath. From the n8n source, node.error.ts:
| Code | Message n8n shows | What actually happened |
|---|---|---|
| ECONNREFUSED | The service refused the connection - perhaps it is offline | Host reached, no listener on the port |
| ENOTFOUND | The connection cannot be established, this usually occurs due to an incorrect host (domain) value | The hostname did not resolve |
| ETIMEDOUT | The connection timed out, consider setting the 'Retry on Fail' option in the node settings | No answer at all within the time allowed |
| ECONNRESET | The connection to the server was closed unexpectedly, perhaps it is offline. You can retry the request immediately or wait and retry later. | Connected, then cut off |
| EHOSTUNREACH | The host is unreachable, perhaps the server is offline | No route to that address |
The distinction matters because each one points somewhere different. A refused connection is good news in one respect: the name resolved and the network path works. You are knocking on a real door and nobody is behind it. So the question is always the same: is this the right door? Usually it is not. The request is going to a machine other than the one you meant.
The error is not specific to the HTTP Request node. Database nodes, the Ollama model nodes and anything else that opens a network connection report it the same way.
Cause 1: localhost Inside Docker Is the n8n Container
The n8n docs call this the most common cause on self-hosted n8n. Inside the n8n container, localhost and 127.0.0.1 point at the container itself, not at the host machine. A request to http://localhost:5000 from a node lands on the n8n container's port 5000, where nothing listens.
It is confusing because the same URL works in your browser. Your browser runs on the host. n8n does not.
How to confirm it: n8n runs in Docker, the target service runs directly on your computer or server, and the URL in the node uses localhost or 127.0.0.1.
The fix on Docker Desktop (Mac or Windows): use http://host.docker.internal:<port> in the URL field. Docker Desktop adds this hostname automatically.
The fix on Linux: the hostname has to be added. Pass --add-host=host.docker.internal:host-gateway to the container, or set extra_hosts in docker-compose.yml:
services:
n8n:
image: n8nio/n8n
extra_hosts:
- "host.docker.internal:host-gateway"
Recreate the container after changing the compose file, then use http://host.docker.internal:<port> in the node.
There is a second half to this that the Ollama page in the n8n docs spells out. The service on the host has to accept connections that do not come from the host's own loopback address. A service bound only to 127.0.0.1 will refuse a connection arriving from a container even when the hostname is right. The docs' instruction for Ollama is to configure it to listen on all interfaces by binding to 0.0.0.0 on the host. The same applies to any local API or database you are trying to reach.
Cause 2: The Target Is Another Container
If the service you are calling also runs in Docker, neither localhost nor host.docker.internal is the right address. Containers reach each other by name.
The n8n docs give the rule for containers on the same Compose stack: use the service name as the hostname, for example http://my-api:5000, and reference the container's internal port, not the published ports: mapping.
The port detail causes a lot of refused connections. If the compose file says ports: "10001:8080", then 10001 is what your host exposes and 8080 is what the service listens on inside its container. From n8n, the address is http://my-api:8080. Calling port 10001 on the service name reaches the right container and finds no listener, which is exactly ECONNREFUSED.
How to confirm it: both n8n and the target are containers, and the URL uses either localhost or a host-side port number.
The fix when both are in one compose file: use the service name and internal port.
The fix when they were started separately: put them on the same user-defined network. The n8n docs give the commands in the Ollama section, and they work for any pair of containers. Replace the names with your own, which you can find with docker ps:
docker network create n8n-shared
docker network connect n8n-shared <target-container>
docker network connect n8n-shared <n8n-container>
Then use http://<target-container>:<internal-port>. The docs add a useful warning: the default Docker bridge network does not resolve container names, and using a container name there can cause an ENOTFOUND error even when the service is running. So if your change turns ECONNREFUSED into ENOTFOUND, you have the right idea and the containers are not yet on a shared user-defined network.
Cause 3: localhost Resolved to IPv6
If the error reads connect ECONNREFUSED ::1:11434 or similar, the giveaway is ::1. That is the IPv6 loopback address.
The n8n docs explain the mechanism: on Node.js 17 and above, even outside Docker, localhost resolves to the IPv6 address ::1 before 127.0.0.1. If the target binds only to 127.0.0.1, the IPv6 attempt is refused, and the fallback to IPv4 does not always succeed inside the HTTP Request node. The Ollama common issues page describes the same thing from the other side: your computer has IPv6 enabled, but Ollama is listening to an IPv4 address.
How to confirm it: the address in the error is ::1, and n8n and the service run on the same machine without Docker in between, for example n8n installed with npm.
The fix: use http://127.0.0.1:<port> in the URL field instead of localhost. For Ollama, change the base URL in the Ollama credential to http://127.0.0.1:11434.
This fix is for the non-Docker case only. If n8n is in a container, 127.0.0.1 is still the container, and you are back at Cause 1.
Cause 4: n8n Cloud Cannot Reach Your Machine
On n8n Cloud, workflows run on n8n's infrastructure. The docs put it bluntly: there is no localhost and no path to a service on your machine. A URL like http://localhost:3000 or http://192.168.1.20:8080 means something on your network and nothing from n8n's servers.
How to confirm it: you are on n8n Cloud and the URL contains localhost, 127.0.0.1, or a private network address.
The fix from the docs: expose local-only targets through a tunnel and use the public URL in the HTTP Request node. That makes a service on your machine reachable from the internet, so put authentication on it and close the tunnel when you are finished testing. For anything permanent, host the service somewhere with a proper public address, or run n8n on the same network as the service. Our guide on running AI agents on your own server covers the second route.
Cause 5: The Service Really Is Not Listening
Sometimes the address is right and the message is literally true. The service is stopped, still starting, crashed, or listening on a different port from the one you typed.
How to confirm it: test from where n8n runs, not from your laptop. The n8n docs give the command for Docker. Exec into the n8n container and try the URL with wget:
docker exec -it n8n wget -qO- http://host.docker.internal:5000/health
Replace n8n with your container's name and the URL with the one from your node. The docs state how to read the result: if wget from inside the container succeeds, the HTTP Request node succeeds too. If wget also returns "connection refused", the cause is the network or the target service, not n8n.
The fix depends on what you find:
- Service stopped: start it, and check its own logs for why it stopped.
- Wrong port: check the port the service reports at startup against the one in the URL.
- Works at some times and not others: the target is restarting or n8n is calling it before it is ready. For a brief gap, open the node's Settings and enable Retry On Fail. The n8n docs note the limits: at most five tries and 5000 ms between tries, so it covers a restart of a few seconds and no more.
How to Stop It Coming Back
Put n8n and its local dependencies in one compose file. Services in the same Compose stack reach each other by service name with no extra configuration. Addresses then never depend on which machine you are on. Our self-hosted LLM agent stack guide shows a full layout with a model server alongside n8n.
Store base URLs in one place. When the same service is called from several nodes, keep its address in a credential or a single configuration node, not typed into each URL field. When the address changes, you change it once.
Use the service name, never an IP address. Container IP addresses change when containers are recreated. Names do not.
Keep the wget test handy. It answers "is it n8n or the network?" in ten seconds and saves you from editing a workflow that was never the problem.
Alert on failure. A service going down is outside your workflow's control, so make sure you hear about it. Set an error workflow in Workflow Settings, starting with the Error Trigger node. See error handling and retry and backoff.
Connecting n8n to local models and private APIs is a large part of building agents you control. The n8n AI Agents course includes the networking setup, and our n8n platform review and the true cost of self-hosting n8n will help you decide whether to self-host at all. If you are choosing a local model server, see Ollama vs vLLM for production agents.
Sources
Checked against n8n's documentation, source code and community forum on 17 November 2026.
- n8n docs: HTTP Request common issues - the Connection refused (ECONNREFUSED) section: Docker,
host.docker.internal,extra_hosts, IPv6, the wget test, n8n Cloud. - n8n docs: Ollama Chat Model common issues - binding to
0.0.0.0, shared Docker networks,ECONNREFUSED ::1:11434. - n8n docs: Handle rate limits - the Retry On Fail limits.
- n8n source: node.error.ts - the error code to message table.
- n8n community: The service refused the connection (n8n and NocoDB) - the localhost-in-a-container case in practice.
FAQ
- What does ECONNREFUSED mean in n8n?
- The node connected to a host and the port it asked for had no listener, so the connection was actively refused. n8n shows it as The service refused the connection - perhaps it is offline. It is different from a DNS failure (ENOTFOUND) or a timeout (ETIMEDOUT).
- Why does localhost not work in n8n when it works in my browser?
- If n8n runs in Docker, localhost inside the container refers to the container itself, not your computer. Your browser runs on the host, so the same URL reaches a different machine. Use host.docker.internal for a service on the host, or the service name for another container.
- How do I make host.docker.internal work on Linux?
- Add it yourself. Pass --add-host=host.docker.internal:host-gateway when starting the container, or add extra_hosts with the entry host.docker.internal:host-gateway under the n8n service in docker-compose.yml, then recreate the container. Docker Desktop on Mac and Windows adds the hostname automatically.
- What does connect ECONNREFUSED ::1 mean?
- ::1 is the IPv6 loopback address. On Node.js 17 and above, localhost resolves to IPv6 first. If the service only listens on IPv4, the connection is refused. Use 127.0.0.1 in the URL instead of localhost.
- How do I connect n8n in Docker to Ollama?
- If Ollama runs on the host, make it listen on 0.0.0.0 and set the Ollama credential's base URL to http://host.docker.internal:11434. If Ollama is in another container, put both containers on the same user-defined Docker network and use http://<ollama-container>:11434.
- Can n8n Cloud call an API running on my computer?
- Not directly. n8n Cloud runs on n8n's infrastructure and has no route to your machine or private network. Expose the service through a tunnel and use its public URL, or host the service at a public address.
- How can I tell whether n8n or the network is at fault?
- Run the request from inside the n8n container: docker exec -it n8n wget -qO- <url>. If wget succeeds, the node will too. If wget is also refused, the problem is the address, the network, or the target service.
If this resonated
Module 02 is the long version of this post.
Eval set, refusal pattern, kill switch. Build it in a weekend.
