axios-retry, got, node-fetch-retry, requestretry, retry-axios, and superagent-retry are npm packages that add automatic retry capabilities to HTTP requests in JavaScript applications. They help developers handle transient network failures—such as timeouts, 5xx server errors, or rate-limiting—by reissuing failed requests according to configurable policies. These libraries differ in their integration approach (plugin vs. built-in), supported HTTP clients, configuration flexibility, and maintenance status.
When building resilient web applications, handling transient network failures is non-negotiable. The packages axios-retry, got, node-fetch-retry, requestretry, retry-axios, and superagent-retry all aim to automate retry logic for failed HTTP requests — but they differ significantly in architecture, flexibility, and ecosystem alignment. Let’s examine how each approaches retries and when to use which.
axios-retry is a plugin that extends the popular axios HTTP client using its interceptor system. It doesn’t replace axios; it enhances it.
import axios from 'axios';
import axiosRetry from 'axios-retry';
axiosRetry(axios, { retries: 3 });
// Now all axios requests will retry automatically
await axios.get('/api/data');
retry-axios (often abbreviated rax) also integrates with axios, but uses a different mechanism: it wraps the request in a retry-aware function that can be applied per-call or globally.
import * as rax from 'retry-axios';
import axios from 'axios';
const interceptorId = rax.attach(); // attaches globally
// Or use per-request:
await rax(axios.get('/api/data'), { retry: 3 });
superagent-retry works similarly as a plugin for the superagent HTTP library. You call .retry() on a request chain.
import superagent from 'superagent';
import 'superagent-retry';
await superagent
.get('/api/data')
.retry(3) // retries up to 3 times
.end();
node-fetch-retry wraps the native-like node-fetch API and adds retry options directly to the fetch call.
import fetchRetry from 'node-fetch-retry';
await fetchRetry('/api/data', {
retries: 3,
retryDelay: 1000
});
requestretry is a full replacement for the now-deprecated request library, bundling retry logic into its core API.
import request from 'requestretry';
request({
url: '/api/data',
maxAttempts: 3,
retryDelay: 1000
}, (err, response, body) => {
// handle result
});
got stands apart: retry logic is built directly into its core design. No plugins needed — retries are a first-class feature.
import got from 'got';
await got('/api/data', {
retry: {
limit: 3,
methods: ['GET', 'PUT']
}
});
⚠️ Important: The
requestlibrary (and by extensionrequestretry) has been officially deprecated since February 2020. Whilerequestretrystill functions, it should not be used in new projects due to lack of modern maintenance and reliance on an outdated HTTP client.
How much control do you get over when and how retries happen?
got offers the most granular control. You can specify:
await got('/api/data', {
retry: {
limit: 3,
methods: ['GET', 'HEAD'],
statusCodes: [408, 413, 429, 500, 502, 503, 504],
calculateDelay: ({ attemptCount }) => Math.pow(2, attemptCount) * 1000
}
});
axios-retry allows custom retry conditions via the retryCondition option and supports exponential backoff through retryDelay.
axiosRetry(axios, {
retries: 3,
retryCondition: (error) => {
return error.response?.status === 503;
},
retryDelay: axiosRetry.exponentialDelay
});
retry-axios provides similar configurability, including custom retry logic and delay strategies.
await rax(axios.get('/api/data'), {
retry: 3,
noResponseRetries: 2,
httpMethodsToRetry: ['GET', 'HEAD'],
statusCodesToRetry: [[100, 199], [429, 429], [500, 599]]
});
superagent-retry is more limited — it retries on network errors and specific status codes (5xx by default), but customization requires overriding internal methods.
superagent
.get('/api/data')
.retry(3, [500, 502, 503]) // only these statuses
.end();
node-fetch-retry supports basic options like retries, retryDelay, and retryOn, but lacks deep customization.
fetchRetry('/api/data', {
retries: 3,
retryOn: (attempt, error, response) => response?.status === 503
});
requestretry allows setting maxAttempts, retryDelay, and retryStrategy, but again, this is built on a deprecated foundation.
All packages support some form of delay between retries, but implementation varies.
got: Full control via calculateDelay function; includes built-in backoff option.axios-retry: Provides exponentialDelay, linearDelay, or custom functions.retry-axios: Uses exponential backoff by default; configurable via currentRetryAttempt.superagent-retry: Simple linear delay; no built-in exponential strategy.node-fetch-retry: Accepts static retryDelay or a function (retryNumber) => delay.requestretry: Supports retryDelay and retryDelayMultiplier for exponential behavior.Your choice often depends on your existing HTTP client:
axios? → Choose axios-retry (more widely adopted) or retry-axios (more Google-centric).superagent? → superagent-retry is your only real option.fetch? → node-fetch-retry gives you retry logic while keeping a familiar API.got is purpose-built for robust HTTP interactions with retries as a core concern.request? → Migrate away; do not start new projects with requestretry.got if you’re in Node.js and need maximum reliability and configurability. It’s actively maintained, modern, and retry logic is deeply integrated.axios-based frontend/backend: axios-retry is the community standard — simple to set up and well-documented.fetch: node-fetch-retry is acceptable for basic needs, but consider wrapping fetch yourself with a lightweight retry utility if requirements grow.requestretry due to its dependency on the deprecated request library. Also avoid mixing multiple retry strategies across your codebase — pick one HTTP client and stick with its retry solution.| Package | Type | HTTP Client | Custom Conditions | Backoff Control | Active Maintenance |
|---|---|---|---|---|---|
axios-retry | Plugin | axios | ✅ | ✅ (predefined + custom) | ✅ |
retry-axios | Wrapper | axios | ✅ | ✅ | ✅ |
superagent-retry | Plugin | superagent | ⚠️ (limited) | ❌ (basic only) | ✅ |
node-fetch-retry | Wrapper | node-fetch | ✅ (basic) | ✅ (simple) | ✅ |
requestretry | Full client | request (deprecated) | ✅ | ✅ | ❌ (avoid) |
got | Built-in | got | ✅ (full) | ✅ (advanced) | ✅ |
Retry logic seems simple until you’re debugging why a critical API call failed silently in production. The right tool gives you visibility, control, and confidence. If you’re already invested in an HTTP client like axios, extend it with its ecosystem’s retry package. But if you’re choosing from scratch — especially for backend services where reliability is paramount — got’s thoughtful, integrated approach makes it the strongest choice today.
Choose got if you're starting a new Node.js project and need a modern, full-featured HTTP client with retry logic built directly into its core. It offers the most granular control over retry conditions, status codes, methods, and backoff strategies, and is actively maintained with a focus on reliability and developer experience.
Choose axios-retry if you're already using axios and want a widely adopted, easy-to-integrate retry plugin that leverages axios interceptors. It supports custom retry conditions and built-in delay strategies like exponential backoff, making it suitable for both frontend and Node.js environments where axios is the standard HTTP client.
Choose retry-axios (also known as rax) if you're in a Google Cloud or TypeScript-heavy environment and need fine-grained control over axios retries, including per-request configuration and detailed status code ranges. It’s a solid alternative to axios-retry, though slightly less common in the broader ecosystem.
Do not choose requestretry for new projects. It extends the request library, which has been officially deprecated since 2020. While it may still work, it lacks modern maintenance, security updates, and compatibility with current Node.js best practices. Migrate existing usage to alternatives like got or axios with retry plugins.
Choose node-fetch-retry if you prefer using a fetch-like API in Node.js and need basic retry functionality without switching HTTP clients. It’s a lightweight wrapper around node-fetch that adds retry options, but lacks the advanced customization found in more specialized libraries like got.
Choose superagent-retry only if your project already relies on the superagent HTTP library and you need simple retry logic. It integrates cleanly via method chaining but offers limited customization for retry conditions and backoff strategies compared to more flexible alternatives.
Sindre's open source work is supported by the community.
Special thanks to:
Human-friendly and powerful HTTP request library for Node.js
See how Got compares to other HTTP libraries
You probably want Ky instead, by the same people. It's smaller, works in the browser too, and is more stable since it's built on Fetch. Or fetch-extras for simple needs.
Support questions should be asked here.
npm install got
Warning: This package is native ESM and no longer provides a CommonJS export. If your project uses CommonJS, you will have to convert to ESM. Please don't open issues for questions regarding CommonJS / ESM.
Got v11 is no longer maintained and we will not accept any backport requests.
A quick start guide is available.
Got has a dedicated option for handling JSON payload.
Furthermore, the promise exposes a .json<T>() function that returns Promise<T>.
import got from 'got';
const {data} = await got.post('https://httpbin.org/anything', {
json: {
hello: 'world'
}
}).json();
console.log(data);
//=> {"hello": "world"}
For advanced JSON usage, check out the parseJson and stringifyJson options.
For more useful tips like this, visit the Tips page.
By default, Got will retry on failure. To disable this option, set options.retry.limit to 0.
got4aws - Got convenience wrapper to interact with AWS v4 signed APIsgh-got - Got convenience wrapper to interact with the GitHub APIgl-got - Got convenience wrapper to interact with the GitLab APIgotql - Got convenience wrapper to interact with GraphQL using JSON-parsed queries instead of stringsgot-fetch - Got with a fetch interfacegot-scraping - Got wrapper specifically designed for web scraping purposesgot-ssrf - Got wrapper to protect server-side requests against SSRF attacksgot | node-fetch | ky | axios | superagent | |
|---|---|---|---|---|---|
| HTTP/2 support | :heavy_check_mark:¹ | :x: | :heavy_check_mark: | :x: | :heavy_check_mark:** |
| Browser support | :x: | :heavy_check_mark:* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Promise API | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Stream API | :heavy_check_mark: | Node.js only | :x: | :x: | :heavy_check_mark: |
| Pagination API | :heavy_check_mark: | :x: | :x: | :x: | :x: |
| Request cancelation | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| RFC compliant caching | :heavy_check_mark: | :x: | :x: | :x: | :x: |
| Cookies (out-of-the-box) | :heavy_check_mark: | :x: | :x: | :x: | :x: |
| Follows redirects | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Retries on failure | :heavy_check_mark: | :x: | :heavy_check_mark: | :x: | :heavy_check_mark: |
| Progress events | :heavy_check_mark: | :x: | :heavy_check_mark: | Browser only | :heavy_check_mark: |
| Handles gzip/deflate | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Advanced timeouts | :heavy_check_mark: | :x: | :x: | :x: | :x: |
| Timings | :heavy_check_mark: | :x: | :x: | :x: | :x: |
| Errors with metadata | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| JSON mode | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Custom defaults | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| Composable | :heavy_check_mark: | :x: | :x: | :x: | :heavy_check_mark: |
| Hooks | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| Issues open | |||||
| Issues closed | |||||
| Downloads | |||||
| Coverage | TBD | ||||
| Build | |||||
| Bugs | |||||
| Dependents | |||||
| Install size | |||||
| GitHub stars | |||||
| TypeScript support | |||||
| Last commit |
* It's almost API compatible with the browser fetch API.
** Need to switch the protocol manually. Doesn't accept PUSH streams and doesn't reuse HTTP/2 sessions.
¹ Requires Node.js 15.10.0 or above.
:sparkle: Almost-stable feature, but the API may change. Don't hesitate to try it out!
:grey_question: Feature in early stage of development. Very experimental.
Click here to see the install size of the Got dependencies.
![]() | ![]() |
|---|---|
| Sindre Sorhus | Szymon Marczak |
|
|
|
|
|
|
|
|
|
|
Segment is a happy user of Got! Got powers the main backend API that our app talks to. It's used by our in-house RPC client that we use to communicate with all microservices.
Antora, a static site generator for creating documentation sites, uses Got to download the UI bundle. In Antora, the UI bundle (aka theme) is maintained as a separate project. That project exports the UI as a zip file we call the UI bundle. The main site generator downloads that UI from a URL using Got and streams it to vinyl-zip to extract the files. Those files go on to be used to create the HTML pages and supporting assets.
GetVoIP is happily using Got in production. One of the unique capabilities of Got is the ability to handle Unix sockets which enables us to build a full control interfaces for our docker stack.
We're using Got inside of Exoframe to handle all the communication between CLI and server. Exoframe is a self-hosted tool that allows simple one-command deployments using Docker.
Karaoke Mugen uses Got to fetch content updates from its online server.
Renovate uses Got, gh-got and gl-got to send millions of queries per day to GitHub, GitLab, npmjs, PyPi, Packagist, Docker Hub, Terraform, CircleCI, and more.
Resistbot uses Got to communicate from the API frontend where all correspondence ingresses to the officials lookup database in back.
Natural Cycles is using Got to communicate with all kinds of 3rd-party REST APIs (over 9000!).
Microlink is a cloud browser as an API service that uses Got widely as the main HTTP client, serving ~22M requests a month, every time a network call needs to be performed.
We’re using Got at Radity. Thanks for such an amazing work!