Skip to content

urllib3.exceptions.NameResolutionError ([Errno -2] Name does not resolve) #76

@igolman

Description

@igolman

Hi 👋

firstly thank you and all supporters that have contributed to the last v1.5.3 release 👍

I've just picked up the latest image and encounter with a problem on my setup. I have to mention in advance, that instead of mounting the docker socket in stackback container directly, I use a "backupproxy" container based on the linuxproxy project. The configuration of a proxy is quite standard:

services:
  backupproxy:
    image: 'linuxserver/socket-proxy:3.2.7'
    container_name: 'backupproxy'
    environment:
      CONTAINERS: 1
      VERSION: 1
      POST: 1
      ALLOW_START: 1
      ALLOW_STOP: 1
    read_only: true
    tmpfs: [ '/run' ]
    volumes: [ '/var/run/docker.sock:/var/run/docker.sock:ro' ]
    restart: 'unless-stopped'
    networks: [ 'backup' ]

the stackback instance is configured with DOCKER_HOST variable instead of a socket mount:

services:
  stackback_s3:
    image: 'ghcr.io/lawndoc/stack-back:v1.5.3'
    volumes:
      - 'backup_s3_cache:/cache'
    restart: 'unless-stopped'
    environment:
      DOCKER_HOST: 'tcp://backupproxy:2375'
      RESTIC_REPOSITORY: "${RESTIC_S3_REPOSITORY:?}"
      RESTIC_PASSWORD: "${RESTIC_S3_PASSPHRASE:?}"
      AWS_ACCESS_KEY_ID: "${RESTIC_AWS_ACCESS_KEY_ID:?}"
      AWS_SECRET_ACCESS_KEY: "${RESTIC_AWS_SECRET_ACCESS_KEY:?}"
      ...
      ...
    networks:
      default:
      backup:

with the v1.4.5 everything was working, however after update to v1.5.3:

  • rcb status is still working
/restic-compose-backup # rcb status --log-level debug
2025-11-10 18:31:47,579 - INFO: Status for compose project 'my-project'
2025-11-10 18:31:47,579 - INFO: Repository: 's3:my-project'
2025-11-10 18:31:47,579 - INFO: Backup currently running?: False
2025-11-10 18:31:47,579 - INFO: Include project name in backup path?: False
2025-11-10 18:31:47,579 - DEBUG: Exclude bind mounts from backups?: False
2025-11-10 18:31:47,579 - DEBUG: Include all compose projects?: False
2025-11-10 18:31:47,579 - DEBUG: Use cache for integrity check?: False
2025-11-10 18:31:47,579 - INFO: Checking docker availability
2025-11-10 18:31:47,641 - INFO: Contacting repository
2025-11-10 18:31:47,641 - DEBUG: cmd: restic -r s3:my-project cat config
2025-11-10 18:31:48,768 - DEBUG: ---------- stdout ----------
2025-11-10 18:31:48,768 - DEBUG: {
2025-11-10 18:31:48,768 - DEBUG:   "version": 2,
2025-11-10 18:31:48,768 - DEBUG:   "id": "30e3595c4d35f1de43178f3a40f175305ce3b542b769741f67532200b6eb3f03",
2025-11-10 18:31:48,768 - DEBUG:   "chunker_polynomial": "2d58bfea5c1187"
2025-11-10 18:31:48,768 - DEBUG: }
2025-11-10 18:31:48,768 - DEBUG: ----------------------------
2025-11-10 18:31:48,768 - DEBUG: returncode 0
...
...
2025-11-10 18:31:48,771 - INFO: -------------------------------------------------------------------
/restic-compose-backup # echo $?
0
  • rcb backup does not:
/restic-compose-backup # rcb backup --log-level debug
2025-11-10 18:32:02,618 - DEBUG: Starting backup container with image ghcr.io/lawndoc/stack-back:v1.5.3
2025-11-10 18:32:02,619 - INFO: Starting backup container
2025-11-10 18:32:02,907 - INFO: Backup process container: magical_easley
Traceback (most recent call last):
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/urllib3/connection.py", line 198, in _new_conn
    sock = connection.create_connection(
        (self._dns_host, self.port),
    ...<2 lines>...
        socket_options=self.socket_options,
    )
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/urllib3/util/connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
               ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/share/uv/python/cpython-3.14.0-linux-x86_64-musl/lib/python3.14/socket.py", line 983, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
               ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -2] Name does not resolve

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

Traceback (most recent call last):
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    response = self._make_request(
        conn,
    ...<10 lines>...
        **response_kw,
    )
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/urllib3/connectionpool.py", line 493, in _make_request
    conn.request(
    ~~~~~~~~~~~~^
        method,
        ^^^^^^^
    ...<6 lines>...
        enforce_content_length=enforce_content_length,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/urllib3/connection.py", line 445, in request
    self.endheaders()
    ~~~~~~~~~~~~~~~^^
  File "/root/.local/share/uv/python/cpython-3.14.0-linux-x86_64-musl/lib/python3.14/http/client.py", line 1333, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/share/uv/python/cpython-3.14.0-linux-x86_64-musl/lib/python3.14/http/client.py", line 1093, in _send_output
    self.send(msg)
    ~~~~~~~~~^^^^^
  File "/root/.local/share/uv/python/cpython-3.14.0-linux-x86_64-musl/lib/python3.14/http/client.py", line 1037, in send
    self.connect()
    ~~~~~~~~~~~~^^
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/urllib3/connection.py", line 276, in connect
    self.sock = self._new_conn()
                ~~~~~~~~~~~~~~^^
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/urllib3/connection.py", line 205, in _new_conn
    raise NameResolutionError(self.host, self, e) from e
urllib3.exceptions.NameResolutionError: <urllib3.connection.HTTPConnection object at 0x799ab4625550>: Failed to resolve 'backupproxy' ([Errno -2] Name does not resolve)

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

Traceback (most recent call last):
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
        method=request.method,
    ...<9 lines>...
        chunked=chunked,
    )
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/urllib3/connectionpool.py", line 841, in urlopen
    retries = retries.increment(
        method, url, error=new_e, _pool=self, _stacktrace=sys.exc_info()[2]
    )
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/urllib3/util/retry.py", line 519, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='backupproxy', port=2375): Max retries exceeded with url: /version (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x799ab4625550>: Failed to resolve 'backupproxy' ([Errno -2] Name does not resolve)"))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/docker/api/client.py", line 223, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
                        ~~~~~~~~~^^^^^
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/docker/utils/decorators.py", line 44, in inner
    return f(self, *args, **kwargs)
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/docker/api/client.py", line 246, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
           ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/requests/adapters.py", line 700, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='backupproxy', port=2375): Max retries exceeded with url: /version (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x799ab4625550>: Failed to resolve 'backupproxy' ([Errno -2] Name does not resolve)"))

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

Traceback (most recent call last):
  File "/restic-compose-backup/.venv/bin/rcb", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "/restic-compose-backup/restic_compose_backup/cli.py", line 23, in main
    containers = RunningContainers()
  File "/restic-compose-backup/restic_compose_backup/containers.py", line 400, in __init__
    all_containers = utils.list_containers()
  File "/restic-compose-backup/restic_compose_backup/utils.py", line 39, in list_containers
    client = docker_client()
  File "/restic-compose-backup/restic_compose_backup/utils.py", line 29, in docker_client
    return docker.from_env()
           ~~~~~~~~~~~~~~~^^
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/docker/client.py", line 94, in from_env
    return cls(
        timeout=timeout,
    ...<3 lines>...
        **kwargs_from_env(**kwargs)
    )
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/docker/client.py", line 45, in __init__
    self.api = APIClient(*args, **kwargs)
               ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/docker/api/client.py", line 207, in __init__
    self._version = self._retrieve_server_version()
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/restic-compose-backup/.venv/lib/python3.14/site-packages/docker/api/client.py", line 230, in _retrieve_server_version
    raise DockerException(
        f'Error while fetching server API version: {e}'
    ) from e
docker.errors.DockerException: Error while fetching server API version: HTTPConnectionPool(host='backupproxy', port=2375): Max retries exceeded with url: /version (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x799ab4625550>: Failed to resolve 'backupproxy' ([Errno -2] Name does not resolve)"))
2025-11-10 18:32:03,774 - DEBUG: Container ExitCode 1
2025-11-10 18:32:03,800 - INFO: Backup container exit code: 1
  • additional information:
    • both backupproxy and stackback instances are in backup docker network
/restic-compose-backup # ping backupproxy
PING backupproxy (10.11.0.2): 56 data bytes
64 bytes from 10.11.0.2: seq=0 ttl=64 time=0.062 ms
64 bytes from 10.11.0.2: seq=1 ttl=64 time=0.156 ms
^C
--- backupproxy ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.062/0.109/0.156 ms
  • switching to direct docker socket mount in stackback solves the problem, i.e. with
services:
  stackback_s3:
    image: 'ghcr.io/lawndoc/stack-back:v1.5.3'
    volumes:
      - '/var/run/docker.sock:/tmp/docker.sock:ro'
      - 'backup_s3_cache:/cache'
    restart: 'unless-stopped'
    environment:
      # DOCKER_HOST: 'tcp://backupproxy:2375'

RFC. Any chance we can sort it out?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions