Skip to content

Redirects do not work on a PoolManager configured with custom retries #3649

@miguelgrinberg

Description

@miguelgrinberg

Subject

This started happening with the 2.5.0 release, as a result of changes made in f05b132. If you create a PoolManager with an explicit number of retries given as an integer, then redirects get disabled. I believe this is not intended.

Environment

Describe your environment.

OS macOS-15.5-arm64-arm-64bit
Python 3.11.10
OpenSSL 3.5.0 8 Apr 2025
urllib3 2.5.0

Steps to Reproduce

Run the following in a Python repl:

import urllib3
http = urllib3.PoolManager(retries=10)
r = http.request("GET", "https://httpbin.org/redirect/1")

Expected Behavior

A response is returned.

Actual Behavior

The request raises the following exception:

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded with url: https://httpbin.org/redirect/1 (Caused by ResponseError('too many redirects'))

Additional details

The error only occurs when the pool is initialized with an integer number of retries. Both not passing retries and passing it set to a Retry instance leave redirects enabled and working as expected. Adding a retries argument to the request() call also works fine, even if an integer is passed as its value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions