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.
Fixes npm ERR! 429 Too Many Requests
# Check retry-after header (if present)
# Wait the specified time, then retry
sleep 60
npm install# Check retry-after header (if present)# Wait the specified time, then retrysleep 60npm installnpm ERR! 429 Too Many Requests
On this page
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.
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.
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.