How to fix npm ERR! 429 Too Many Requests in npm
The HTTP 429 Too Many Requests error occurs when you've exceeded npm registry rate limits. This is common in CI/CD environments with many concurrent jobs or during aggressive scripting.
Quick fix
Fixes npm ERR! 429 Too Many Requests
# Check retry-after header (if present)
# Wait the specified time, then retry
sleep 60
npm install- Wait and retry
- Enable npm caching
- Use npm ci with caching in CI
- Authenticate to get higher limits
# Check retry-after header (if present)# Wait the specified time, then retrysleep 60npm installnpm ERR! 429 Too Many Requests
What this error means
HTTP 429 is a rate limiting response - you've made too many requests to the npm registry in a short time period. The registry implements rate limiting to ensure fair access for all users and protect against abuse. Rate limits apply to both authenticated and anonymous users, with authenticated users typically getting higher limits. CI/CD environments often hit these limits due to parallel jobs all requesting packages simultaneously.
Typical symptoms
- npm install fails with 429 error
- Error occurs during CI/CD pipeline runs
- Multiple concurrent builds failing
- Error mentions rate limit or throttling
- Works after waiting, then fails again
- Intermittent failures in automation
Common causes
- Too many concurrent npm requests
- Parallel CI/CD jobs
- Aggressive scripting or automation
- Missing package caching
- Large monorepo with many packages
- Anonymous requests (lower limits)
- Shared IP with other npm users
How to fix "npm ERR! 429 Too Many Requests"
Respect the rate limit:
# Check retry-after header (if present)
# Wait the specified time, then retry
sleep 60
npm installRate limits typically reset within minutes.
Cache packages to reduce requests:
# Local cache is automatic, but verify
npm config get cache
# Force cache usage
npm install --prefer-offlineOptimize CI/CD:
# GitHub Actions
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
- run: npm ciLog in for increased rate limits:
npm login
# Or use token in CI
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKENLimit concurrency:
# Reduce concurrent connections
npm config set maxsockets 3
# In CI, stagger job starts
# Or use a single install job that cachesUse a caching proxy:
# Use Verdaccio, Nexus, or Artifactory as proxy
npm config set registry http://npm-proxy.company.comThis reduces direct registry requests.
Advanced notes
For large organizations, npm Enterprise or a self-hosted registry eliminates public rate limits. Consider using pnpm or yarn which have different request patterns. In Kubernetes, use a shared npm cache volume or service. Monitor registry response headers for rate limit information. GitHub Actions cache can persist across workflow runs.
Frequently asked questions
- What does "npm ERR! 429 Too Many Requests" mean?
- HTTP 429 is a rate limiting response - you've made too many requests to the npm registry in a short time period. The registry implements rate limiting to ensure fair access for all users and protect against abuse. Rate limits apply to both authenticated and anonymous users, with authenticated users typically getting higher limits.
- How do I fix "npm ERR! 429 Too Many Requests"?
- The HTTP 429 Too Many Requests error occurs when you've exceeded npm registry rate limits. This is common in CI/CD environments with many concurrent jobs or during aggressive scripting.
- What causes "npm ERR! 429 Too Many Requests"?
- Too many concurrent npm requests Parallel CI/CD jobs Aggressive scripting or automation
- Is the "npm ERR! 429 Too Many Requests" 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
- ๐
- ๐