diff --git a/lib/promscrape/client.go b/lib/promscrape/client.go index 2a1524c82..34492b5a8 100644 --- a/lib/promscrape/client.go +++ b/lib/promscrape/client.go @@ -91,7 +91,7 @@ func (c *client) ReadData(dst []byte) ([]byte, error) { resp := fasthttp.AcquireResponse() err := doRequestWithPossibleRetry(c.hc, req, resp) statusCode := resp.StatusCode() - if statusCode == fasthttp.StatusMovedPermanently || statusCode == fasthttp.StatusFound { + if err == nil && (statusCode == fasthttp.StatusMovedPermanently || statusCode == fasthttp.StatusFound) { // Allow a single redirect. // It is expected that the redirect is made on the same host. // Otherwise it won't work.