How to fix npm ERR! code EINVALIDPROXY npm ERR! Invalid proxy configuration in npm
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- Check current npm proxy configuration
- Clear invalid proxy settings
- Verify proxy URL format
- URL-encode special characters in passwords
npm config listnpm ERR! code EINVALIDPROXYnpm 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
- 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
- Using https:// protocol for https-proxy instead of http://
- Spaces or invalid characters in proxy configuration
- Global or local .npmrc file contains malformed proxy entries
How to fix "npm ERR! code EINVALIDPROXY npm ERR! Invalid proxy configuration"
View your current npm configuration to identify the problematic proxy settings:
npm config listAlso check if proxy is set in environment variables:
# On Linux/macOS
echo $http_proxy
echo $https_proxyIf you're not behind a proxy or have invalid configuration, remove the proxy settings:
npm config delete proxy
npm config delete https-proxy
npm config delete http-proxyIf you need a proxy, ensure it follows the correct format:
# 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:8080Note: Always use http:// prefix for both proxy and https-proxy, not https://.
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:
npm config set proxy http://user:pass%40word%23123@proxyhost.com:8080If npm config commands don't work, manually edit your .npmrc file at ~/.npmrc:
proxy=http://proxyhost.com:8080
https-proxy=http://proxyhost.com:8080
strict-ssl=falseAdvanced 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
- 📚npm Official Documentation
- 📖npm Docs: npm config(Official Docs)
- 📖npm Docs: Proxy Configuration(Official Docs)
- 💬Stack Overflow: npm Proxy Issues(Stack Overflow)