How to fix npm ERR! code E406 npm ERR! 406 Not Acceptable in npm
The npm E406 error occurs when the npm registry server rejects your request due to incompatible Accept headers or misconfigured registry settings. This commonly happens with custom registries like Artifactory, Nexus, or private repositories.
Quick fix
Fixes npm ERR! code E406 npm ERR! 406 Not Acceptable
npm config get registry- Verify your current registry configuration
- Validate the registry URL format
- Clear npm cache and retry
- Reset to default registry and test
npm config get registrynpm ERR! code E406npm ERR! 406 Not Acceptable
What this error means
HTTP 406 Not Acceptable is a client error response that indicates the server has received your request and the resource exists, but it cannot provide a response matching the content type your npm client is requesting. This typically happens when: 1. Your npm client sends an Accept header (like `application/vnd.npm.install-v1+json`) that the registry server doesn't understand or support. 2. The registry is a private repository (Artifactory, Nexus, etc.) that doesn't fully implement the npm registry specification. 3. The registry URL path is incorrect, preventing proper content type negotiation. The 406 error is essentially a communication mismatch between your npm client and the remote package server.
Typical symptoms
- npm install, npm update, or npm ci fails with 'ERR! code E406'
- Error occurs specifically when using a custom or private npm registry
- Command works fine with the default npmjs.org registry but fails with your configured registry
- Installing from GitHub or GitLab repositories results in 406 errors
- Error message includes 'fetch failed with status code 406' or '406 Not Acceptable'
Common causes
- Custom registry (Artifactory, Nexus, GitLab, etc.) doesn't support the Accept headers npm sends
- Registry URL is incorrectly configured - missing API path or using wrong protocol
- Private registry doesn't fully implement npm registry specification and fails content negotiation
- Older versions of Nexus (2.x) lack support for scoped packages like @types/node
- Proxy or firewall between client and registry modifies or blocks npm's Accept headers
How to fix "npm ERR! code E406 npm ERR! 406 Not Acceptable"
First, check which registry npm is currently configured to use:
npm config get registryIf you see a custom registry URL (not https://registry.npmjs.org/), that's likely where the issue is. Take note of the full URL for the next steps.
Ensure your registry URL follows the correct format:
For Artifactory:
npm config set registry https://artifacts.company.com/artifactory/api/npm/npm-remote/For Nexus 3:
npm config set registry https://nexus.company.com/repository/npm/For GitLab:
npm config set registry https://gitlab.company.com/api/v4/packages/npm/The key is including the /api/ or /repository/ path that points to the npm proxy/repository.
Clear any cached data that might be causing issues:
npm cache clean --forceThen attempt your install again:
npm installThis removes stale cache entries that might be interfering with content negotiation.
Temporarily switch to the official npm registry to isolate the problem:
npm config set registry https://registry.npmjs.org/
npm installIf this succeeds, the issue is with your custom registry configuration. If it fails, the problem is elsewhere (network, authentication, etc.). Once confirmed, switch back to your custom registry and check the URL format from Step 2.
For GitHub dependencies in package.json, use the git:// protocol instead of https://:
{
"dependencies": {
"my-package": "git://github.com/user/repo.git#branch-name"
}
}For private registries requiring authentication, ensure your .npmrc has the correct credentials:
npm login --registry=https://artifacts.company.com/artifactory/api/npm/npm-remote/Or add to .npmrc:
@myorg:registry=https://artifacts.company.com/artifactory/api/npm/npm-remote/
//artifacts.company.com/artifactory/api/npm/npm-remote/:_authToken=YOUR_TOKEN_HEREAdvanced notes
If you're running Nexus 2.x with scoped packages (@myorg/package), upgrade to Nexus 3.x which has full npm scoped package support. For Artifactory users, ensure you're pointing to the correct repository path that proxies npmjs.org. Some older private registries may not correctly implement the npm Accept header specification (application/vnd.npm.install-v1+json); in these cases, contact your registry administrator for an update or configuration adjustment. Use npm install --verbose to see exact headers being sent and responses received.
Frequently asked questions
- What does "npm ERR! code E406 npm ERR! 406 Not Acceptable" mean?
- HTTP 406 Not Acceptable is a client error response that indicates the server has received your request and the resource exists, but it cannot provide a response matching the content type your npm client is requesting. This typically happens when: 1. install-v1+json) that the registry server doesn't understand or support.
- How do I fix "npm ERR! code E406 npm ERR! 406 Not Acceptable"?
- The npm E406 error occurs when the npm registry server rejects your request due to incompatible Accept headers or misconfigured registry settings. This commonly happens with custom registries like Artifactory, Nexus, or private repositories.
- What causes "npm ERR! code E406 npm ERR! 406 Not Acceptable"?
- Custom registry (Artifactory, Nexus, GitLab, etc.) doesn't support the Accept headers npm sends Registry URL is incorrectly configured - missing API path or using wrong protocol Private registry doesn't fully implement npm registry specification and fails content negotiation
- Is the "npm ERR! code E406 npm ERR! 406 Not Acceptable" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- ๐npm Official Documentation
- ๐Docs: npm CLI documentation(Official Docs)
- ๐ฌSO: npm 406 Not Acceptable(Stack Overflow)
- ๐GitHub: npm issues(GitHub)