A Go HTTP client wrapper that automatically retries failed requests with exponential backoff.
go-retryablehttp is a Go library that provides an HTTP client with automatic retries and exponential backoff. It wraps the standard net/http package to handle transient failures like connection errors or server issues, making HTTP requests more reliable in production environments.
Go developers building applications that make HTTP requests to external services, especially in distributed systems where network reliability is critical.
Developers choose go-retryablehttp because it offers a near drop-in replacement for Go's standard HTTP client with built-in resilience features, eliminating the need to manually implement retry logic while maintaining full compatibility with existing code.
Retryable HTTP client in Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Almost identical API to net/http makes integration seamless, as stated in the README: 'exposes nearly the same public API' and 'very easy to drop into existing programs.'
Handles transient failures by retrying on connection errors and 500-range responses (except 501), reducing manual error handling and improving reliability in distributed systems.
Supports multiple ways to provide request bodies that can be rewound for retries, enabling efficient retry of POST/PUT requests without re-creating bodies from scratch.
Can be converted to a standard *http.Client using StandardClient(), allowing use in libraries or frameworks that require the stdlib interface, as shown in the example.
Only retries on connection errors and 500-range status codes, lacking customization for other scenarios like 429 (rate limiting) or 401 (authentication), as per the README's fixed criteria.
Requires Go 1.12+ from version 0.6.1 and Go 1.13+ from 0.6.7, which may not be compatible with projects using older Go versions, as noted in the README.
Focuses solely on retries without built-in circuit breaking, rate limiting, or advanced logging, which are common in more comprehensive resilience libraries, limiting its scope for complex fault tolerance.