npm and pnpm read proxy and https-proxy from .npmrc. Yarn Classic (1.x) stores the same two keys through yarn config. Yarn Berry (2 and later) ignores both and reads httpProxy and httpsProxy from .yarnrc.yml. The standard proxy environment variables work as a fallback for most of them. This guide reflects the tools as of November 2026.
Which proxy settings does each package manager read?
The three tools share a registry but not a config file. Check yarn --version first, because Yarn 1 and Yarn 2+ behave like different programs. The table is the quick map; the sections below give the commands.
| Tool | Config file | Keys |
|---|---|---|
| npm | ~/.npmrc, project .npmrc | proxy, https-proxy, noproxy |
| pnpm | same .npmrc files | https-proxy, http-proxy, proxy, noproxy |
| Yarn Classic 1.x | ~/.yarnrc | proxy, https-proxy |
| Yarn Berry 2+ | .yarnrc.yml | httpProxy, httpsProxy |
How do I set a proxy for npm?
Use npm config set for both keys. The registry is served over HTTPS, so https-proxy matters most, but setting proxy as well avoids surprises. The value is an HTTP proxy URL, with credentials inline if the proxy needs them.
npm config set proxy http://proxy.example.com:8080
npm config set https-proxy http://proxy.example.com:8080
npm config set noproxy "localhost,127.0.0.1,.internal.example.com"
npm config get https-proxy
npm ping
# remove
npm config delete proxy
npm config delete https-proxy
These commands write to ~/.npmrc. Use npm config list to see where each value comes from; a stale line in a project-level .npmrc overrides your user file. For one-off use, the environment is cleaner: HTTPS_PROXY and HTTP_PROXY are honored, and any key can be given as npm_config_ followed by the key name with underscores, such as npm_config_https_proxy. For URL syntax and percent-encoding of passwords, see the rules in setting a proxy for git; they are the same.
How do I set a proxy for pnpm?
pnpm reads the same .npmrc files, so the npm keys carry over. Its documented network keys are https-proxy, http-proxy, proxy and noproxy, and it also falls back to the proxy environment variables.
pnpm config set https-proxy http://proxy.example.com:8080
pnpm config set http-proxy http://proxy.example.com:8080
pnpm config get https-proxy
Newer pnpm releases have been moving settings toward pnpm-workspace.yaml with camelCase names. Which form your version prefers is documented on pnpm.io for that version, so check the page for the release you run instead of assuming.
How do I set a proxy for Yarn, Classic or Berry?
Yarn Classic uses yarn config set with the same key names as npm. Yarn Berry does not read .npmrc at all; it reads .yarnrc.yml in the project or your home directory, with different key names. Setting the wrong file is the most common reason a Yarn 3 or 4 install ignores a proxy.
# Yarn Classic (1.x)
yarn config set proxy http://proxy.example.com:8080
yarn config set https-proxy http://proxy.example.com:8080
# Yarn Berry (2+): .yarnrc.yml
httpProxy: "http://proxy.example.com:8080"
httpsProxy: "http://proxy.example.com:8080"
Berry also has yarn config set httpProxy ... if you prefer a command to editing the file.
Can I use a SOCKS5 proxy with these tools?
Treat the documented answer as HTTP proxy URLs only. The npm, pnpm and Yarn docs describe proxy keys that take an HTTP(S) proxy URL, and SOCKS support has varied between versions. If your proxy offers both protocols, point these tools at the HTTP port. If you only have SOCKS5, run a small local HTTP-to-SOCKS forwarder, or check the docs for your exact version before relying on a socks5:// value.
Why does the install still fail after I set the proxy?
Most failures fall into a few buckets, and the error code tells you which one. Run the install again with npm install --loglevel verbose (or the equivalent flag for your tool) and read the first network error, not the last.
- ETIMEDOUT or ECONNREFUSED to the proxy host: wrong host, port or scheme, or a firewall in between.
- 407 Proxy Authentication Required: missing or wrong credentials; check percent-encoding.
- ECONNRESET partway through: a flaky path; retry, or lower concurrency.
- Certificate errors (SELF_SIGNED_CERT_IN_CHAIN, UNABLE_TO_VERIFY_LEAF_SIGNATURE): a proxy that inspects TLS. Add its CA with
cafile; do not turn offstrict-sslas a habit. - Works for install, fails in a postinstall step: packages that download binaries often use their own downloader, which reads environment variables, not
.npmrc. ExportHTTPS_PROXYas well.
Also keep proxy and registry apart in your head. registry chooses which server to ask; the proxy chooses the path to reach it. Changing one does not replace the other.
How do I pass the proxy in CI?
In CI the least invasive option is to set environment variables for the job and leave every config file alone. npm and pnpm read them, and so do many postinstall download scripts. Add NO_PROXY for internal hosts, and keep secrets in your CI secret store rather than in the repository.
export HTTP_PROXY=http://proxy.example.com:8080
export HTTPS_PROXY=http://proxy.example.com:8080
export NO_PROXY=localhost,127.0.0.1,.internal.example.com
npm ci
Before the install step, run npm ping once. If it fails, the log shows that the proxy path is the problem and not a missing dependency.
Where AnboVPN fits
AnboVPN's HTTP/SOCKS5 proxy gives each account an exclusive IP with an HTTP port (including HTTPS tunnels) and a SOCKS5 port behind one username and password. For package managers, the HTTP form is the one to use. A source-IP allowlist means a build machine can reach the proxy without a password, which keeps credentials out of a shared .npmrc. If you reset the password, the old one stops working after roughly 30 seconds, so refresh any file that embeds it. See the HTTP/SOCKS5 proxy page.


