Domain resolution fails for python requests-package in multithreading scenario

I am having a microservice hosted as an Azure Web App that sends outbound HTTP-POST calls based on various events. The calls have the characteristics of “fire-and-forget”. Thus, I start a thread for each performed HTTP-request as follows:

t = threading.Thread(target=self.perform_call, args=(target_url, notification_dto), daemon=True)
t.name = f'notification_sending_{notification_dto.id}'
t.start()

The request itself is executed via the requests-package as follows (without any explicit session-management etc.):

response = requests.post(target_url, timeout=5, headers=headers_dict, data=data_str)

Sporadically, I see the following error in my log-file:

Traceback (most recent call last):
File “/agents/python/urllib3/connection.py”, line 203, in _new_conn
sock = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/agents/python/urllib3/util/connection.py”, line 60, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/python/3.11.8/lib/python3.11/socket.py”, line 962, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -2] Name or service not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/agents/python/urllib3/connectionpool.py”, line 790, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File “/agents/python/urllib3/connectionpool.py”, line 491, in _make_request
raise new_e
File “/agents/python/urllib3/connectionpool.py”, line 467, in _make_request
self._validate_conn(conn)
File “/agents/python/urllib3/connectionpool.py”, line 1096, in _validate_conn
conn.connect()
File “/agents/python/urllib3/connection.py”, line 611, in connect
self.sock = sock = self._new_conn()
^^^^^^^^^^^^^^^^
File “/agents/python/urllib3/connection.py”, line 210, in _new_conn
raise NameResolutionError(self.host, self, e) from e
urllib3.exceptions.NameResolutionError: <urllib3.connection.HTTPSConnection object at 0x7b7340378a90>: Failed to resolve ‘[here is the hostname: removed for the stackoverflow question]’ ([Errno -2] Name or service not known)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/agents/python/requests/adapters.py”, line 486, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File “/agents/python/wrapt/wrappers.py”, line 669, in call
return self._self_wrapper(self.wrapped, self._self_instance,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/agents/python/opentelemetry/instrumentation/urllib3/init.py”, line 228, in instrumented_urlopen
return wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File “/agents/python/urllib3/connectionpool.py”, line 844, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File “/agents/python/urllib3/util/retry.py”, line 515, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='[here is the hostname: removed for the stackoverflow question]’, port=443): Max retries exceeded with url: /api/test/v1/update (Caused by NameResolutionError(“<urllib3.connection.HTTPSConnection object at 0x7b7340378a90>: Failed to resolve ‘[here is the hostname: removed for the stackoverflow question]’ ([Errno -2] Name or service not known)”))

This happens for about 1 of 50 requests. They are all handled by the same machine, but in different threads (as described). I would be very thankful for any ideas regarding root causes.

I tried to reproduce the error on my local mac but this seems to be difficult.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật