Need help with go-retryablehttp?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

1.0K Stars 156 Forks Mozilla Public License 2.0 119 Commits 29 Opened issues


Retryable HTTP client in Go

Services available


Need anything else?

Contributors list


Build Status Go Documentation


package provides a familiar HTTP client interface with automatic retries and exponential backoff. It is a thin wrapper over the standard
client library and exposes nearly the same public API. This makes
very easy to drop into existing programs.

performs automatic retries under certain conditions. Mainly, if an error is returned by the client (connection errors, etc.), or if a 500-range response code is received (except 501), then a retry is invoked after a wait period. Otherwise, the response is returned and left to the caller to interpret.

The main difference from

is that requests which take a request body (POST/PUT et. al) can have the body provided in a number of ways (some more or less efficient) that allow "rewinding" the request body if the initial request fails so that the full request can be attempted again. See the godoc for more details.

Version 0.6.0 and before are compatible with Go prior to 1.12. From 0.6.1 onward, Go 1.12+ is required. From 0.6.7 onward, Go 1.13+ is required.

Example Use

Using this library should look almost identical to what you would do with

. The most simple example of a GET request is shown below:
resp, err := retryablehttp.Get("/foo")
if err != nil {

The returned response object is an

, the same thing you would usually get from
. Had the request failed one or more times, the above call would block and retry with exponential backoff.

Getting a stdlib
with retries

It's possible to convert a

directly to a
. This makes use of retryablehttp broadly applicable with minimal effort. Simply configure a
as you wish, and then call
retryClient := retryablehttp.NewClient()
retryClient.RetryMax = 10

standardClient := retryClient.StandardClient() // *http.Client

For more usage and examples see the godoc.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.