How to fix npm ERR! code EINVALIDPROXY npm ERR! Invalid proxy configuration in npm

npmBEGINNERMEDIUMUpdated Dec 3, 2025· 192 views

The EINVALIDPROXY error occurs when npm detects malformed proxy settings in your configuration. This typically happens when the proxy URL is missing the protocol prefix (http:// or https://), contains unencoded special characters, or has incorrect formatting.

Quick fix

Fixes EINVALIDPROXY

npm config list
  1. Check current npm proxy configuration
  2. Clear invalid proxy settings
  3. Verify proxy URL format
  4. URL-encode special characters in passwords
npm — error
npm config list
npm ERR! code EINVALIDPROXY
npm ERR! Invalid proxy configuration

What this error means

npm validates proxy configuration during package installation. When it encounters a proxy setting that doesn't follow the required URL format (protocol://[user:password@]host:port), it throws EINVALIDPROXY and halts the installation. This is a safety mechanism to prevent npm from attempting to use malformed proxy servers.

Typical symptoms

  • npm install fails with 'npm ERR! code EINVALIDPROXY'
  • npm ERR! Invalid proxy configuration message appears
  • Package installation hangs or fails immediately when proxy is configured
  • npm commands work fine without proxy settings
  • Warnings like 'Must be a full url with http://' appear

Common causes

  1. Proxy URL missing http:// or https:// protocol prefix
  2. Special characters in password not URL-encoded (@ should be %40, # should be %23)
  3. Backslashes in domain\\username not properly escaped as %5C
  4. Using https:// protocol for https-proxy instead of http://
  5. Spaces or invalid characters in proxy configuration
  6. Global or local .npmrc file contains malformed proxy entries

How to fix "npm ERR! code EINVALIDPROXY npm ERR! Invalid proxy configuration"

1Check current npm proxy configuration

View your current npm configuration to identify the problematic proxy settings:

bash
npm config list

Also check if proxy is set in environment variables:

bash
# On Linux/macOS
echo $http_proxy
echo $https_proxy
2Clear invalid proxy settings

If you're not behind a proxy or have invalid configuration, remove the proxy settings:

bash
npm config delete proxy
npm config delete https-proxy
npm config delete http-proxy
3Verify proxy URL format

If you need a proxy, ensure it follows the correct format:

bash
# Basic format (no auth)
npm config set proxy http://proxyhost.com:8080
npm config set https-proxy http://proxyhost.com:8080

# With authentication
npm config set proxy http://username:password@proxyhost.com:8080

Note: Always use http:// prefix for both proxy and https-proxy, not https://.

4URL-encode special characters in passwords

If your proxy password contains special characters, they must be URL-encoded:

- @ → %40
- # → %23
- : → %3A
- \\ → %5C

Example: If password is pass@word#123, set it as:

bash
npm config set proxy http://user:pass%40word%23123@proxyhost.com:8080
5Edit .npmrc file directly

If npm config commands don't work, manually edit your .npmrc file at ~/.npmrc:

bash
proxy=http://proxyhost.com:8080
https-proxy=http://proxyhost.com:8080
strict-ssl=false

Advanced notes

For corporate environments with NTLM proxies, npm may not work directly. Install an intermediate proxy server like Cntlm that translates NTLM authentication to basic HTTP authentication, then point npm to your local proxy (e.g., http://localhost:3128). Some corporate networks also require strict-ssl=false in .npmrc to bypass certificate validation warnings.

Frequently asked questions

What does "EINVALIDPROXY" mean?
npm validates proxy configuration during package installation. When it encounters a proxy setting that doesn't follow the required URL format (protocol://[user:password@]host:port), it throws EINVALIDPROXY and halts the installation. This is a safety mechanism to prevent npm from attempting to use malformed proxy servers.
How do I fix "EINVALIDPROXY"?
The EINVALIDPROXY error occurs when npm detects malformed proxy settings in your configuration. This typically happens when the proxy URL is missing the protocol prefix (http:// or https://), contains unencoded special characters, or has incorrect formatting.
What causes "EINVALIDPROXY"?
Proxy URL missing http:// or https:// protocol prefix Special characters in password not URL-encoded (@ should be %40, # should be %23) Backslashes in domain\\username not properly escaped as %5C
Is the "EINVALIDPROXY" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading