Skip to content
Guides 2 Connection Type: 1 views

Setting up a proxy for npm, yarn, and p

How to configure a proxy for Node.js package managers: npm, yarn, and pnpm. Configuration, authentication, and registry.

Configuring Proxies for npm, yarn, and pnpm

Introduction

Node.js package managers (npm, yarn, pnpm) download packages from the npm registry. In a corporate network or when using a proxy for anonymity, it's necessary to configure a proxy for these package managers to function correctly.

Basic Configuration

npm

npm config set proxy http://proxy_ip:port
npm config set https-proxy http://proxy_ip:port

With authentication:
npm config set proxy http://user:pass@proxy_ip:port

Verification:
npm config get proxy

Removal:
npm config delete proxy
npm config delete https-proxy

yarn

yarn config set proxy http://proxy_ip:port
yarn config set https-proxy http://proxy_ip:port

pnpm

pnpm config set proxy http://proxy_ip:port
pnpm config set https-proxy http://proxy_ip:port

Alternatively, via environment variables: HTTP_PROXY, HTTPS_PROXY — this works for all three managers.

Advanced Configuration

Environment Variables

Most tools support standard environment variables for proxies:
- HTTP_PROXY / http_proxy — proxy for HTTP requests
- HTTPS_PROXY / https_proxy — proxy for HTTPS requests
- NO_PROXY / no_proxy — list of exclusions (addresses that bypass the proxy)
- ALL_PROXY / all_proxy — proxy for all protocols

SSL and Self-Signed Certificates

Corporate proxies often use their own SSL certificates. To work through them, you need to:
1. Obtain the proxy's CA certificate from the administrator
2. Add it to your system's certificate store
3. Or disable SSL verification (for testing only)

Authentication

Two main authentication methods are supported:

Username and Password — standard HTTP Basic authentication. Credentials are sent with each request. URL format: http://user:pass@proxy_ip:port

By IP Address (whitelist) — your IP is added to a whitelist. No credentials need to be sent.

Verifying the Setup

After configuration, verify:
1. Perform a test request through the proxy
2. Ensure your IP address has changed
3. Check the connection speed
4. Confirm there are no DNS leaks

Troubleshooting

Proxy Fails to Connect

  • Check the address and port for correctness
  • Ensure your firewall isn't blocking the connection
  • Verify the proxy's accessibility from your network

SSL Errors

  • For corporate proxies, add the CA certificate
  • For testing, temporarily disable SSL verification
  • Update SSL libraries to the latest version

Authentication Errors

  • Check your username and password
  • Ensure the credentials format is correct
  • Try URL encoding special characters in the password

Best Practices

  1. Use environment variables — for flexibility and security
  2. Avoid hardcoding credentials — use environment variables or configuration files
  3. Configure exclusions — do not proxy localhost and internal addresses
  4. Document settings — in your project's README or team wiki
  5. Test after changes — any configuration change requires verification

Conclusion

Correct proxy configuration ensures stable tool operation and secure connections. Follow the recommendations in this guide and always verify functionality after setup.

Auto-update: 06.03.2026
All Categories

Advantages of our proxies

25,000+ proxies from 120+ countries