litellm - ✅(Solved) Fix [Bug]: Provider ChatGPT not using Proxy/IPv4 for Device Binding [1 pull requests, 2 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#24562Fetched 2026-04-08 01:27:05
View on GitHub
Comments
2
Participants
1
Timeline
7
Reactions
0
Participants
Timeline (top)
labeled ×3commented ×2cross-referenced ×1subscribed ×1

Error Message

{"message": "Error creating deployment: litellm.BadRequestError: GetLLMProvider Exception - Failed to request device code: [Errno -9] Address family for hostname not supported\n\noriginal model: chatgpt/gpt-5.3-codex-spark, ignoring and continuing with other deployments.", "level": "ERROR", "timestamp": "2026-03-25T10:17:57.973308", "stacktrace": "Traceback (most recent call last):\n File "/usr/lib/python3.13/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions\n yield\n File "/usr/lib/python3.13/site-packages/httpx/_transports/default.py", line 250, in handle_request\n resp = self._pool.handle_request(req)\n File "/usr/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py", line 256, in handle_request\n raise exc from None\n File "/usr/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py", line 236, in handle_request\n response = connection.handle_request(\n pool_request.request\n )\n File "/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py", line 101, in handle_request\n raise exc\n File "/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py", line 78, in handle_request\n stream = self._connect(request)\n File "/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py", line 124, in _connect\n stream = self._network_backend.connect_tcp(**kwargs)\n File "/usr/lib/python3.13/site-packages/httpcore/_backends/sync.py", line 207, in connect_tcp\n with map_exceptions(exc_map):\n ~~~~~~~~~~~~~~^^^^^^^^^\n File "/usr/lib/python3.13/contextlib.py", line 162, in exit\n self.gen.throw(value)\n ~~~~~~~~~~~~~~^^^^^^^\n File "/usr/lib/python3.13/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions\n raise to_exc(exc) from exc\nhttpcore.ConnectError: [Errno -9] Address family for hostname not supported\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py", line 178, in _request_device_code\n resp = client.post(\n CHATGPT_DEVICE_CODE_URL,\n json={"client_id": CHATGPT_CLIENT_ID},\n )\n File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 1049, in post\n raise e\n File "/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py", line 1028, in post\n response = self.client.send(req, stream=stream)\n File "/usr/lib/python3.13/site-packages/httpx/_client.py", line 914, in send\n response = self._send_handling_auth(\n request,\n ...<2 lines>...\n history=[],\n )\n File "/usr/lib/python3.13/site-packages/httpx/_client.py", line 942, in _send_handling_auth\n response = self._send_handling_redirects(\n request,\n follow_redirects=follow_redirects,\n history=history,\n )\n File "/usr/lib/python3.13/site-packages/httpx/_client.py", line 979, in _send_handling_redirects\n response = self._send_single_request(request)\n File "/usr/lib/python3.13/site-packages/httpx/_client.py", line 1014, in _send_single_request\n response = transport.handle_request(request)\n File "/usr/lib/python3.13/site-packages/httpx/_transports/default.py", line 249, in handle_request\n with map_httpcore_exceptions():\n ~~~~~~~~~~~~~~~~~~~~~~~^^\n File "/usr/lib/python3.13/contextlib.py", line 162, in exit\n self.gen.throw(value)\n ~~~~~~~~~~~~~~^^^^^^^\n File "/usr/lib/python3.13/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions\n raise mapped_exc(message) from exc\nhttpx.ConnectError: [Errno -9] Address family for hostname not supported\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py", line 190, in get_llm_provider\n return _get_openai_compatible_provider_info(\n model=model,\n ...<2 lines>...\n dynamic_REDACTED,\n )\n File "/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py", line 795, in _get_openai_compatible_provider_info\n ) = litellm.ChatGPTConfig()._get_openai_compatible_provider_info(\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n model, api_base, api_key, custom_llm_provider\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File "/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/chat/transformation.py", line 35, in _get_openai_compatible_provider_info\n dynamic_REDACTED)\n File "/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py", line 71, in get_access_token\n tokens = self._login_device_code()\n File "/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py", line 160, in _login_device_code\n device_code = self._request_device_code()\n File "/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py", line 190, in _request_device_code\n raise GetDeviceCodeError(\n ...<2 lines>...\n )\nlitellm.llms.chatgpt.common_utils.GetDeviceCodeError: Failed to request device code: [Errno -9] Address family for hostname not supported\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "/usr/lib/python3.13/site-packages/litellm/router.py", line 6585, in _create_deployment\n deployment = self._add_deployment(deployment=deployment)\n File "/usr/lib/python3.13/site-packages/litellm/router.py", line 6837, in _add_deployment\n ) = litellm.get_llm_provider(\n ~~~~~~~~~~~~~~~~~~~~~~~~^\n model=deployment.litellm_params.model,\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n ...<2 lines>...\n ),\n ^^\n )\n ^\n File "/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py", line 495, in get_llm_provider\n raise litellm.exceptions.BadRequestError( # type: ignore\n ...<4 lines>...\n )\nlitellm.exceptions.BadRequestError: litellm.BadRequestError: GetLLMProvider Exception - Failed to request device code: [Errno -9] Address family for hostname not supported\n\noriginal model: chatgpt/gpt-5.3-codex-spark"}

Fix Action

Fix / Workaround

services:
    litellm:
        command:
        - --config=/app/config.yaml
        env_file:
        - /opt/docker/.litellm-secrets-env
        #extra_hosts:
        #  - auth.openai.com:104.18.41.241
        environment:
            CHATGPT_API_BASE: https://chatgpt.com/backend-api/codex
            CHATGPT_AUTH_FILE: auth.json
            CHATGPT_TOKEN_DIR: /token
            LITELLM_LOG: "debug"
            LITELLM_MODEL_COST_MAP_URL: "https://git.xxx.xxx/xxx/litellm/raw/branch/main/model_prices_and_context_window.json"
            STORE_MODEL_IN_DB: 'True'
            http_proxy: http://<redacted>:8080
            https_proxy: http://<redacted>:8080
            no_proxy: <redacted>
        healthcheck:
            interval: 30s
            retries: 3
            start_period: 40s
            test:
            - CMD-SHELL
            - python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:4000/health/liveliness')"
            timeout: 10s
        image: <redacted>/litellm/litellm-non_root:v1.82.3-stable.patch.2
        logging:
            driver: loki
            options:
                loki-url: https://<redacted>/loki/api/v1/push
                max-file: '5'
                max-size: 64m
        ports:
        - 4000:4000
        restart: always
        volumes:
        - <redacted>/config.yaml:/app/config.yaml
        - <redacted>:/token

v1.82.3-stable.patch.2

PR fix notes

PR #24569: feat: Implement proxy mount configuration for httpx clients

Description (problem / solution / changelog)

Added a method to create proxy mount configuration for httpx clients based on environment variables.

Relevant issues

Fixes partly https://github.com/BerriAI/litellm/issues/24562

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

<!-- Select the type of Pull Request --> <!-- Keep only the necessary ones -->

🆕 New Feature 🐛 Bug Fix 🧹 Refactoring 📖 Documentation 🚄 Infrastructure ✅ Test

Changes

Changed files

  • litellm/llms/custom_httpx/http_handler.py (modified, +25/-1)

Code Example

{"message": "Error creating deployment: litellm.BadRequestError: GetLLMProvider Exception - Failed to request device code: [Errno -9] Address family for hostname not supported\n\noriginal model: chatgpt/gpt-5.3-codex-spark, ignoring and continuing with other deployments.", "level": "ERROR", "timestamp": "2026-03-25T10:17:57.973308", "stacktrace": "Traceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 101, in map_httpcore_exceptions\n    yield\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 250, in handle_request\n    resp = self._pool.handle_request(req)\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py\", line 256, in handle_request\n    raise exc from None\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py\", line 236, in handle_request\n    response = connection.handle_request(\n        pool_request.request\n    )\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py\", line 101, in handle_request\n    raise exc\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py\", line 78, in handle_request\n    stream = self._connect(request)\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py\", line 124, in _connect\n    stream = self._network_backend.connect_tcp(**kwargs)\n  File \"/usr/lib/python3.13/site-packages/httpcore/_backends/sync.py\", line 207, in connect_tcp\n    with map_exceptions(exc_map):\n         ~~~~~~~~~~~~~~^^^^^^^^^\n  File \"/usr/lib/python3.13/contextlib.py\", line 162, in __exit__\n    self.gen.throw(value)\n    ~~~~~~~~~~~~~~^^^^^^^\n  File \"/usr/lib/python3.13/site-packages/httpcore/_exceptions.py\", line 14, in map_exceptions\n    raise to_exc(exc) from exc\nhttpcore.ConnectError: [Errno -9] Address family for hostname not supported\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 178, in _request_device_code\n    resp = client.post(\n        CHATGPT_DEVICE_CODE_URL,\n        json={\"client_id\": CHATGPT_CLIENT_ID},\n    )\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py\", line 1049, in post\n    raise e\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py\", line 1028, in post\n    response = self.client.send(req, stream=stream)\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 914, in send\n    response = self._send_handling_auth(\n        request,\n    ...<2 lines>...\n        history=[],\n    )\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 942, in _send_handling_auth\n    response = self._send_handling_redirects(\n        request,\n        follow_redirects=follow_redirects,\n        history=history,\n    )\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 979, in _send_handling_redirects\n    response = self._send_single_request(request)\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 1014, in _send_single_request\n    response = transport.handle_request(request)\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 249, in handle_request\n    with map_httpcore_exceptions():\n         ~~~~~~~~~~~~~~~~~~~~~~~^^\n  File \"/usr/lib/python3.13/contextlib.py\", line 162, in __exit__\n    self.gen.throw(value)\n    ~~~~~~~~~~~~~~^^^^^^^\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 118, in map_httpcore_exceptions\n    raise mapped_exc(message) from exc\nhttpx.ConnectError: [Errno -9] Address family for hostname not supported\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py\", line 190, in get_llm_provider\n    return _get_openai_compatible_provider_info(\n        model=model,\n    ...<2 lines>...\n        dynamic_REDACTED,\n    )\n  File \"/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py\", line 795, in _get_openai_compatible_provider_info\n    ) = litellm.ChatGPTConfig()._get_openai_compatible_provider_info(\n        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n        model, api_base, api_key, custom_llm_provider\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    )\n    ^\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/chat/transformation.py\", line 35, in _get_openai_compatible_provider_info\n    dynamic_REDACTED)\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 71, in get_access_token\n    tokens = self._login_device_code()\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 160, in _login_device_code\n    device_code = self._request_device_code()\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 190, in _request_device_code\n    raise GetDeviceCodeError(\n    ...<2 lines>...\n    )\nlitellm.llms.chatgpt.common_utils.GetDeviceCodeError: Failed to request device code: [Errno -9] Address family for hostname not supported\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/router.py\", line 6585, in _create_deployment\n    deployment = self._add_deployment(deployment=deployment)\n  File \"/usr/lib/python3.13/site-packages/litellm/router.py\", line 6837, in _add_deployment\n    ) = litellm.get_llm_provider(\n        ~~~~~~~~~~~~~~~~~~~~~~~~^\n        model=deployment.litellm_params.model,\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    ...<2 lines>...\n        ),\n        ^^\n    )\n    ^\n  File \"/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py\", line 495, in get_llm_provider\n    raise litellm.exceptions.BadRequestError(  # type: ignore\n    ...<4 lines>...\n    )\nlitellm.exceptions.BadRequestError: litellm.BadRequestError: GetLLMProvider Exception - Failed to request device code: [Errno -9] Address family for hostname not supported\n\noriginal model: chatgpt/gpt-5.3-codex-spark"}

---

extra_hosts:
          - auth.openai.com:104.18.41.241

---

{"message": "Error creating deployment: litellm.BadRequestError: GetLLMProvider Exception - Failed to request device code: litellm.Timeout: Connection timed out after None seconds.\n\noriginal model: chatgpt/gpt-4o-mini, ignoring and continuing with other deployments.", "level": "ERROR", "timestamp": "2026-03-25T10:13:16.346713", "stacktrace": "Traceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 101, in map_httpcore_exceptions\n    yield\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 250, in handle_request\n    resp = self._pool.handle_request(req)\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py\", line 256, in handle_request\n    raise exc from None\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py\", line 236, in handle_request\n    response = connection.handle_request(\n        pool_request.request\n    )\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py\", line 101, in handle_request\n    raise exc\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py\", line 78, in handle_request\n    stream = self._connect(request)\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py\", line 124, in _connect\n    stream = self._network_backend.connect_tcp(**kwargs)\n  File \"/usr/lib/python3.13/site-packages/httpcore/_backends/sync.py\", line 207, in connect_tcp\n    with map_exceptions(exc_map):\n         ~~~~~~~~~~~~~~^^^^^^^^^\n  File \"/usr/lib/python3.13/contextlib.py\", line 162, in __exit__\n    self.gen.throw(value)\n    ~~~~~~~~~~~~~~^^^^^^^\n  File \"/usr/lib/python3.13/site-packages/httpcore/_exceptions.py\", line 14, in map_exceptions\n    raise to_exc(exc) from exc\nhttpcore.ConnectTimeout: timed out\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py\", line 1028, in post\n    response = self.client.send(req, stream=stream)\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 914, in send\n    response = self._send_handling_auth(\n        request,\n    ...<2 lines>...\n        history=[],\n    )\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 942, in _send_handling_auth\n    response = self._send_handling_redirects(\n        request,\n        follow_redirects=follow_redirects,\n        history=history,\n    )\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 979, in _send_handling_redirects\n    response = self._send_single_request(request)\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 1014, in _send_single_request\n    response = transport.handle_request(request)\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 249, in handle_request\n    with map_httpcore_exceptions():\n         ~~~~~~~~~~~~~~~~~~~~~~~^^\n  File \"/usr/lib/python3.13/contextlib.py\", line 162, in __exit__\n    self.gen.throw(value)\n    ~~~~~~~~~~~~~~^^^^^^^\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 118, in map_httpcore_exceptions\n    raise mapped_exc(message) from exc\nhttpx.ConnectTimeout: timed out\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 178, in _request_device_code\n    resp = client.post(\n        CHATGPT_DEVICE_CODE_URL,\n        json={\"client_id\": CHATGPT_CLIENT_ID},\n    )\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py\", line 1032, in post\n    raise litellm.Timeout(\n    ...<3 lines>...\n    )\nlitellm.exceptions.Timeout: litellm.Timeout: Connection timed out after None seconds.\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py\", line 190, in get_llm_provider\n    return _get_openai_compatible_provider_info(\n        model=model,\n    ...<2 lines>...\n        dynamic_REDACTED,\n    )\n  File \"/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py\", line 795, in _get_openai_compatible_provider_info\n    ) = litellm.ChatGPTConfig()._get_openai_compatible_provider_info(\n        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n        model, api_base, api_key, custom_llm_provider\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    )\n    ^\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/chat/transformation.py\", line 35, in _get_openai_compatible_provider_info\n    dynamic_REDACTED)\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 71, in get_access_token\n    tokens = self._login_device_code()\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 160, in _login_device_code\n    device_code = self._request_device_code()\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 190, in _request_device_code\n    raise GetDeviceCodeError(\n    ...<2 lines>...\n    )\nlitellm.llms.chatgpt.common_utils.GetDeviceCodeError: Failed to request device code: litellm.Timeout: Connection timed out after None seconds.\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/router.py\", line 6585, in _create_deployment\n    deployment = self._add_deployment(deployment=deployment)\n  File \"/usr/lib/python3.13/site-packages/litellm/router.py\", line 6837, in _add_deployment\n    ) = litellm.get_llm_provider(\n        ~~~~~~~~~~~~~~~~~~~~~~~~^\n        model=deployment.litellm_params.model,\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    ...<2 lines>...\n        ),\n        ^^\n    )\n    ^\n  File \"/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py\", line 495, in get_llm_provider\n    raise litellm.exceptions.BadRequestError(  # type: ignore\n    ...<4 lines>...\n    )\nlitellm.exceptions.BadRequestError: litellm.BadRequestError: GetLLMProvider Exception - Failed to request device code: litellm.Timeout: Connection timed out after None seconds.\n\noriginal model: chatgpt/gpt-4o-mini"}

---

services:
    litellm:
        command:
        - --config=/app/config.yaml
        env_file:
        - /opt/docker/.litellm-secrets-env
        #extra_hosts:
        #  - auth.openai.com:104.18.41.241
        environment:
            CHATGPT_API_BASE: https://chatgpt.com/backend-api/codex
            CHATGPT_AUTH_FILE: auth.json
            CHATGPT_TOKEN_DIR: /token
            LITELLM_LOG: "debug"
            LITELLM_MODEL_COST_MAP_URL: "https://git.xxx.xxx/xxx/litellm/raw/branch/main/model_prices_and_context_window.json"
            STORE_MODEL_IN_DB: 'True'
            http_proxy: http://<redacted>:8080
            https_proxy: http://<redacted>:8080
            no_proxy: <redacted>
        healthcheck:
            interval: 30s
            retries: 3
            start_period: 40s
            test:
            - CMD-SHELL
            - python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:4000/health/liveliness')"
            timeout: 10s
        image: <redacted>/litellm/litellm-non_root:v1.82.3-stable.patch.2
        logging:
            driver: loki
            options:
                loki-url: https://<redacted>/loki/api/v1/push
                max-file: '5'
                max-size: 64m
        ports:
        - 4000:4000
        restart: always
        volumes:
        - <redacted>/config.yaml:/app/config.yaml
        - <redacted>:/token

---

see above
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

When using LiteLLM + Squid proxy + ChatGPT Provider, its unable to bind the device id

First issue: if an ipv6 address is resolvable, its also used, even if ipv6 is disabled. (both on the linux host and via config parameter force_ipv4: True

{"message": "Error creating deployment: litellm.BadRequestError: GetLLMProvider Exception - Failed to request device code: [Errno -9] Address family for hostname not supported\n\noriginal model: chatgpt/gpt-5.3-codex-spark, ignoring and continuing with other deployments.", "level": "ERROR", "timestamp": "2026-03-25T10:17:57.973308", "stacktrace": "Traceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 101, in map_httpcore_exceptions\n    yield\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 250, in handle_request\n    resp = self._pool.handle_request(req)\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py\", line 256, in handle_request\n    raise exc from None\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py\", line 236, in handle_request\n    response = connection.handle_request(\n        pool_request.request\n    )\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py\", line 101, in handle_request\n    raise exc\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py\", line 78, in handle_request\n    stream = self._connect(request)\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py\", line 124, in _connect\n    stream = self._network_backend.connect_tcp(**kwargs)\n  File \"/usr/lib/python3.13/site-packages/httpcore/_backends/sync.py\", line 207, in connect_tcp\n    with map_exceptions(exc_map):\n         ~~~~~~~~~~~~~~^^^^^^^^^\n  File \"/usr/lib/python3.13/contextlib.py\", line 162, in __exit__\n    self.gen.throw(value)\n    ~~~~~~~~~~~~~~^^^^^^^\n  File \"/usr/lib/python3.13/site-packages/httpcore/_exceptions.py\", line 14, in map_exceptions\n    raise to_exc(exc) from exc\nhttpcore.ConnectError: [Errno -9] Address family for hostname not supported\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 178, in _request_device_code\n    resp = client.post(\n        CHATGPT_DEVICE_CODE_URL,\n        json={\"client_id\": CHATGPT_CLIENT_ID},\n    )\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py\", line 1049, in post\n    raise e\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py\", line 1028, in post\n    response = self.client.send(req, stream=stream)\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 914, in send\n    response = self._send_handling_auth(\n        request,\n    ...<2 lines>...\n        history=[],\n    )\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 942, in _send_handling_auth\n    response = self._send_handling_redirects(\n        request,\n        follow_redirects=follow_redirects,\n        history=history,\n    )\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 979, in _send_handling_redirects\n    response = self._send_single_request(request)\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 1014, in _send_single_request\n    response = transport.handle_request(request)\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 249, in handle_request\n    with map_httpcore_exceptions():\n         ~~~~~~~~~~~~~~~~~~~~~~~^^\n  File \"/usr/lib/python3.13/contextlib.py\", line 162, in __exit__\n    self.gen.throw(value)\n    ~~~~~~~~~~~~~~^^^^^^^\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 118, in map_httpcore_exceptions\n    raise mapped_exc(message) from exc\nhttpx.ConnectError: [Errno -9] Address family for hostname not supported\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py\", line 190, in get_llm_provider\n    return _get_openai_compatible_provider_info(\n        model=model,\n    ...<2 lines>...\n        dynamic_REDACTED,\n    )\n  File \"/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py\", line 795, in _get_openai_compatible_provider_info\n    ) = litellm.ChatGPTConfig()._get_openai_compatible_provider_info(\n        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n        model, api_base, api_key, custom_llm_provider\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    )\n    ^\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/chat/transformation.py\", line 35, in _get_openai_compatible_provider_info\n    dynamic_REDACTED)\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 71, in get_access_token\n    tokens = self._login_device_code()\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 160, in _login_device_code\n    device_code = self._request_device_code()\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 190, in _request_device_code\n    raise GetDeviceCodeError(\n    ...<2 lines>...\n    )\nlitellm.llms.chatgpt.common_utils.GetDeviceCodeError: Failed to request device code: [Errno -9] Address family for hostname not supported\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/router.py\", line 6585, in _create_deployment\n    deployment = self._add_deployment(deployment=deployment)\n  File \"/usr/lib/python3.13/site-packages/litellm/router.py\", line 6837, in _add_deployment\n    ) = litellm.get_llm_provider(\n        ~~~~~~~~~~~~~~~~~~~~~~~~^\n        model=deployment.litellm_params.model,\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    ...<2 lines>...\n        ),\n        ^^\n    )\n    ^\n  File \"/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py\", line 495, in get_llm_provider\n    raise litellm.exceptions.BadRequestError(  # type: ignore\n    ...<4 lines>...\n    )\nlitellm.exceptions.BadRequestError: litellm.BadRequestError: GetLLMProvider Exception - Failed to request device code: [Errno -9] Address family for hostname not supported\n\noriginal model: chatgpt/gpt-5.3-codex-spark"}

Adding a fixed ipv4 address to the docker compose file for the host will resolve this issue:

        extra_hosts:
          - auth.openai.com:104.18.41.241

But then there is another issue:

  {"message": "Error creating deployment: litellm.BadRequestError: GetLLMProvider Exception - Failed to request device code: litellm.Timeout: Connection timed out after None seconds.\n\noriginal model: chatgpt/gpt-4o-mini, ignoring and continuing with other deployments.", "level": "ERROR", "timestamp": "2026-03-25T10:13:16.346713", "stacktrace": "Traceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 101, in map_httpcore_exceptions\n    yield\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 250, in handle_request\n    resp = self._pool.handle_request(req)\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py\", line 256, in handle_request\n    raise exc from None\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py\", line 236, in handle_request\n    response = connection.handle_request(\n        pool_request.request\n    )\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py\", line 101, in handle_request\n    raise exc\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py\", line 78, in handle_request\n    stream = self._connect(request)\n  File \"/usr/lib/python3.13/site-packages/httpcore/_sync/connection.py\", line 124, in _connect\n    stream = self._network_backend.connect_tcp(**kwargs)\n  File \"/usr/lib/python3.13/site-packages/httpcore/_backends/sync.py\", line 207, in connect_tcp\n    with map_exceptions(exc_map):\n         ~~~~~~~~~~~~~~^^^^^^^^^\n  File \"/usr/lib/python3.13/contextlib.py\", line 162, in __exit__\n    self.gen.throw(value)\n    ~~~~~~~~~~~~~~^^^^^^^\n  File \"/usr/lib/python3.13/site-packages/httpcore/_exceptions.py\", line 14, in map_exceptions\n    raise to_exc(exc) from exc\nhttpcore.ConnectTimeout: timed out\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py\", line 1028, in post\n    response = self.client.send(req, stream=stream)\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 914, in send\n    response = self._send_handling_auth(\n        request,\n    ...<2 lines>...\n        history=[],\n    )\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 942, in _send_handling_auth\n    response = self._send_handling_redirects(\n        request,\n        follow_redirects=follow_redirects,\n        history=history,\n    )\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 979, in _send_handling_redirects\n    response = self._send_single_request(request)\n  File \"/usr/lib/python3.13/site-packages/httpx/_client.py\", line 1014, in _send_single_request\n    response = transport.handle_request(request)\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 249, in handle_request\n    with map_httpcore_exceptions():\n         ~~~~~~~~~~~~~~~~~~~~~~~^^\n  File \"/usr/lib/python3.13/contextlib.py\", line 162, in __exit__\n    self.gen.throw(value)\n    ~~~~~~~~~~~~~~^^^^^^^\n  File \"/usr/lib/python3.13/site-packages/httpx/_transports/default.py\", line 118, in map_httpcore_exceptions\n    raise mapped_exc(message) from exc\nhttpx.ConnectTimeout: timed out\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 178, in _request_device_code\n    resp = client.post(\n        CHATGPT_DEVICE_CODE_URL,\n        json={\"client_id\": CHATGPT_CLIENT_ID},\n    )\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/custom_httpx/http_handler.py\", line 1032, in post\n    raise litellm.Timeout(\n    ...<3 lines>...\n    )\nlitellm.exceptions.Timeout: litellm.Timeout: Connection timed out after None seconds.\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py\", line 190, in get_llm_provider\n    return _get_openai_compatible_provider_info(\n        model=model,\n    ...<2 lines>...\n        dynamic_REDACTED,\n    )\n  File \"/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py\", line 795, in _get_openai_compatible_provider_info\n    ) = litellm.ChatGPTConfig()._get_openai_compatible_provider_info(\n        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n        model, api_base, api_key, custom_llm_provider\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    )\n    ^\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/chat/transformation.py\", line 35, in _get_openai_compatible_provider_info\n    dynamic_REDACTED)\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 71, in get_access_token\n    tokens = self._login_device_code()\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 160, in _login_device_code\n    device_code = self._request_device_code()\n  File \"/usr/lib/python3.13/site-packages/litellm/llms/chatgpt/authenticator.py\", line 190, in _request_device_code\n    raise GetDeviceCodeError(\n    ...<2 lines>...\n    )\nlitellm.llms.chatgpt.common_utils.GetDeviceCodeError: Failed to request device code: litellm.Timeout: Connection timed out after None seconds.\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/lib/python3.13/site-packages/litellm/router.py\", line 6585, in _create_deployment\n    deployment = self._add_deployment(deployment=deployment)\n  File \"/usr/lib/python3.13/site-packages/litellm/router.py\", line 6837, in _add_deployment\n    ) = litellm.get_llm_provider(\n        ~~~~~~~~~~~~~~~~~~~~~~~~^\n        model=deployment.litellm_params.model,\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n    ...<2 lines>...\n        ),\n        ^^\n    )\n    ^\n  File \"/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/get_llm_provider_logic.py\", line 495, in get_llm_provider\n    raise litellm.exceptions.BadRequestError(  # type: ignore\n    ...<4 lines>...\n    )\nlitellm.exceptions.BadRequestError: litellm.BadRequestError: GetLLMProvider Exception - Failed to request device code: litellm.Timeout: Connection timed out after None seconds.\n\noriginal model: chatgpt/gpt-4o-mini"}

So the auth call is not using the configured http/https proxy, which LiteLLM is using.

services:
    litellm:
        command:
        - --config=/app/config.yaml
        env_file:
        - /opt/docker/.litellm-secrets-env
        #extra_hosts:
        #  - auth.openai.com:104.18.41.241
        environment:
            CHATGPT_API_BASE: https://chatgpt.com/backend-api/codex
            CHATGPT_AUTH_FILE: auth.json
            CHATGPT_TOKEN_DIR: /token
            LITELLM_LOG: "debug"
            LITELLM_MODEL_COST_MAP_URL: "https://git.xxx.xxx/xxx/litellm/raw/branch/main/model_prices_and_context_window.json"
            STORE_MODEL_IN_DB: 'True'
            http_proxy: http://<redacted>:8080
            https_proxy: http://<redacted>:8080
            no_proxy: <redacted>
        healthcheck:
            interval: 30s
            retries: 3
            start_period: 40s
            test:
            - CMD-SHELL
            - python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:4000/health/liveliness')"
            timeout: 10s
        image: <redacted>/litellm/litellm-non_root:v1.82.3-stable.patch.2
        logging:
            driver: loki
            options:
                loki-url: https://<redacted>/loki/api/v1/push
                max-file: '5'
                max-size: 64m
        ports:
        - 4000:4000
        restart: always
        volumes:
        - <redacted>/config.yaml:/app/config.yaml
        - <redacted>:/token

Steps to Reproduce

  1. Configure LiteLLM with Squid proxy
  2. Enable Provider https://docs.litellm.ai/docs/providers/chatgpt
  3. Start LiteLLM

Relevant log output

see above

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.82.3-stable.patch.2

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

To resolve the issue, we need to ensure that the auth call uses the configured HTTP/HTTPS proxy.

  • Set the http_proxy and https_proxy environment variables in the litellm service.
  • Update the authenticator.py file to use the proxy settings.

Here's an example of how to update the authenticator.py file:

import os
import httpx

# ...

def _request_device_code(self):
    # Get the proxy settings from the environment variables
    http_proxy = os.environ.get('http_proxy')
    https_proxy = os.environ.get('https_proxy')

    # Create a new HTTP client with the proxy settings
    client = httpx.Client(
        proxies={
            'http': http_proxy,
            'https': https_proxy,
        }
    )

    # Use the new client to make the request
    resp = client.post(
        CHATGPT_DEVICE_CODE_URL,
        json={'client_id': CHATGPT_CLIENT_ID},
    )

    # ...

Alternatively, you can also use the requests library with the proxies parameter:

import os
import requests

# ...

def _request_device_code(self):
    # Get the proxy settings from the environment variables
    http_proxy = os.environ.get('http_proxy')
    https_proxy = os.environ.get('https_proxy')

    # Create a new session with the proxy settings
    session = requests.Session()
    session.proxies = {
        'http': http_proxy,
        'https': https_proxy,
    }

    # Use the new session to make the request
    resp = session.post(
        CHATGPT_DEVICE_CODE_URL,
        json={'client_id': CHATGPT_CLIENT_ID},
    )

    # ...

Verification

To verify that the fix worked, you can check the logs for any errors related to the proxy settings. You can also test the auth call by running the litellm service with the updated authenticator.py file.

Extra Tips

Make sure to update the litellm service to use the latest version of the authenticator.py file. Also, ensure that the http_proxy and https_proxy environment variables are set correctly in the litellm service.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING