Change8
Error1 reports

Fix LocalProtocolError

in httpx

Solution

LocalProtocolError in httpx often arises from modifying data structures (like request headers or the connection pool) while they are being iterated over or used by httpx's internal processes during a request. To resolve this, ensure that you create copies of data structures before modifying them, especially when dealing with request headers or connection pool parameters within middleware or event hooks. Specifically, use `.copy()` on dictionaries or create new lists from deques before iterating and modifying them.

Related Issues

Real GitHub issues where developers encountered this error:

Timeline

First reported:May 9, 2025
Last reported:May 9, 2025

Need More Help?

View the full changelog and migration guides for httpx

View httpx Changelog