“npm error code ECONNREFUSED” on Mac

ECONNREFUSED reports a refused connection. Node.js documentation says: “No connection could be made because the target machine actively refused it.”

Fix this with your agentCopies a prompt for Claude Code, Codex or any agent that can use Terminal.

My Mac has this problem: “npm error code ECONNREFUSED” on Mac. Read https://kilobat.app/guides/npm-econnrefused.md and work through it with me. Install the Kilobat CLI if it’s missing: brew install seifip/kilobat/kilobat. Run the guide’s Terminal and kilobat checks yourself and tell me what you find. List the steps only I can do. Ask before you change any setting.

Applies to: npm 10 and later print “npm error”. Older versions print “npm ERR!”. Node.js on all current macOS versions.Checked: 29 October 2026

Symptoms

  • npm install or a script stops with npm error code ECONNREFUSED.
  • The next line names an address and a port, such as 127.0.0.1:8080.
  • It often follows a proxy or registry setting.

Likely causes

  • A proxy setting that points to nothing. A proxy on 127.0.0.1 or another host is set, but no proxy runs there.
  • A local registry that is off. A local mirror or cache is down.
  • A service that is inactive. Node.js documentation says this usually results from a service that is inactive on the remote host.
  • A script that calls a local server. A test or build step can call a server that has not started.

How to check

  1. Read the address and port in the error.

  2. Show npm’s proxy and registry.

    npm config get proxy
    npm config get https-proxy
    npm config get registry
  3. Test that port.

    nc -vz 127.0.0.1 8080
  4. Show the proxy variables.

    env | grep -i proxy

How to fix it

  1. Delete a proxy setting that you do not need.

    npm config delete proxy
    npm config delete https-proxy
  2. Start the local registry or server that the address names.

  3. Unset wrong proxy variables.

    unset https_proxy http_proxy
  4. Retry the install.

Questions

Is ECONNREFUSED the same as ECONNRESET?

No. ECONNREFUSED is a refusal at the start. ECONNRESET closes an open connection. See “npm error code ECONNRESET” on Mac.

Why does it name 127.0.0.1?

npm tried a local address, usually from a proxy or registry setting.

Sources

Checked on 29 October 2026.