---
title: "“npm error code ECONNREFUSED” on Mac · Kilobat Guides"
url: "https://kilobat.app/guides/npm-econnrefused"
description: "npm install on your Mac stops with npm error code ECONNREFUSED. A host refused the connection. Check the registry, proxy and local services."
---

# “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 agent**Copies 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](https://kilobat.app/guides/npm-econnreset).

**Why does it name 127.0.0.1?**

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

## Sources

- [Node.js documentation: Common system errors](https://nodejs.org/api/errors.html#common-system-errors)
- [npm Docs: Common errors](https://docs.npmjs.com/common-errors)

Checked on 29 October 2026.

## Related guides

- [“npm error code ECONNRESET” on Mac](https://kilobat.app/guides/npm-econnreset): ECONNRESET reports a forcibly reset connection.
- [“npm error code ENOTFOUND” on Mac](https://kilobat.app/guides/npm-enotfound): ENOTFOUND reports a failed DNS lookup.
- [ERR_CONNECTION_REFUSED in Chrome on Mac](https://kilobat.app/guides/err-connection-refused): ERR_CONNECTION_REFUSED is a Chrome network error.
- [Proxy settings stop apps from connecting on a Mac](https://kilobat.app/guides/proxy-settings-breaking-apps): A proxy setting sends traffic through another server.
