encode / httpx

A next generation HTTP client for Python. 🦋

Home Page:https://www.python-httpx.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

httpx.ConnectError: [Errno -2] Name or service not known using Docker Supabase Image

the-rich-piana opened this issue · comments

Discussed in #2967

Originally posted by the-rich-piana November 29, 2023
Hello,

I'm using a Docker container for data processing which interacts with another Docker database container. The database container is a variety of Supabase images (an open source DB). As data is processed it is written to this Postgres / Supabase database.

Frankly I'm not sure what's happening, I have zero understanding of how the httpx package works.
Would really appreciate some help if someone could maybe walk me through whats happening here.

The only other issue which mentions this is here: #1311

But that issue is related to some experimental Docker Ipv6 address feature. Which I don't believe is the case here (using ipv4).

Environment:
OS: Ubuntu 23 LTS
Python version: 3.10
HTTPX version: httpx = "^0.23.0"
Async environment: ?
HTTP proxy: ?
Custom certificates: ?

Error:

  File "/usr/local/lib/python3.10/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions
    yield
  File "/usr/local/lib/python3.10/site-packages/httpcore/backends/sync.py", line 94, in connect_tcp
    sock = socket.create_connection(
  File "/usr/local/lib/python3.10/socket.py", line 824, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/local/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 218, in handle_request
    resp = self._pool.handle_request(req)
  File "/usr/local/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 253, in handle_request
    raise exc
  File "/usr/local/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 237, in handle_request
    response = connection.handle_request(request)
  File "/usr/local/lib/python3.10/site-packages/httpcore/_sync/connection.py", line 86, in handle_request
    raise exc
  File "/usr/local/lib/python3.10/site-packages/httpcore/_sync/connection.py", line 63, in handle_request
    stream = self._connect(request)
  File "/usr/local/lib/python3.10/site-packages/httpcore/_sync/connection.py", line 111, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/httpcore/backends/sync.py", line 93, in connect_tcp
    with map_exceptions(exc_map):
  File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.10/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc)
httpcore.ConnectError: [Errno -2] Name or service not known

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

Traceback (most recent call last):
  File "/app/sandbox.py", line 93, in <module>
    task = processor_diarize_transcribe(pd)
  File "/usr/local/lib/python3.10/site-packages/celery/local.py", line 188, in __call__
    return self._get_current_object()(*a, **kw)
  File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 392, in __call__
    return self.run(*args, **kwargs)
  File "/app/worker.py", line 566, in processor_diarize_transcribe
    doc = Document.from_id(pd.document_id)
  File "/app/database/supabase_model.py", line 70, in from_id
    return supabase_model.populate_from_unique_fields(id=id)
  File "/app/database/supabase_model.py", line 149, in populate_from_unique_fields
    response = query.execute()
  File "/usr/local/lib/python3.10/site-packages/postgrest/_sync/request_builder.py", line 55, in execute
    r = self.session.request(
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 821, in request
    return self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 908, in send
    response = self._send_handling_auth(
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 936, in _send_handling_auth
    response = self._send_handling_redirects(
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 973, in _send_handling_redirects
    response = self._send_single_request(request)
  File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1009, in _send_single_request
    response = transport.handle_request(request)
  File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 217, in handle_request
    with map_httpcore_exceptions():
  File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno -2] Name or service not known```</div>