Skip to content

ADK Web Server Connection Error with Google AI Studio #2595

@vpsiddhant

Description

@vpsiddhant

Describe the bug

The ADK web server fails to communicate with the Google AI API when trying to run an agent, resulting in an httpx.ConnectError during the TLS handshake phase. The error occurs when the agent attempts to generate content using the gemini-2.0-flash model.

To Reproduce

Steps to reproduce the behavior:

  1. Install Google ADK version 1.11.0 using pip install google-adk
  2. Follow the quickstart tutorial to create a multi-tool agent project: https://google.github.io/adk-docs/get-started/quickstart/#run-your-agent
  3. Set up .env file with GOOGLE_GENAI_USE_VERTEXAI=FALSE and a valid GOOGLE_API_KEY
  4. Run adk web command from the parent directory
  5. Open the web interface and try to interact with the agent
  6. See connection error in the terminal logs

Expected behavior

The agent should successfully connect to the Google AI API and respond to user queries about weather and time in New York, as demonstrated in the quickstart tutorial.

Screenshots

Error logs show the foll

Image Image

The error occurs during the TLS connection establishment phase when trying to reach the Google AI API endpoints.

Desktop (please complete the following information):

  • OS: macOS (darwin 24.6.0)
  • Python version: Python 3.13.7
  • ADK version: 1.11.0

Model Information:

Using gemini-2.0-flash model with Google AI Studio API (not Vertex AI)

Additional context

  • I am able to use the gemini api directly via the generative ai client https://ai.google.dev/gemini-api/docs/quickstart
  • ONLY ADK seems to be having this issue
  • The agent code follows the exact quickstart tutorial from the ADK documentation
  • The .env configuration is set up correctly with GOOGLE_GENAI_USE_VERTEXAI=FALSE and a valid API key
  • The error occurs during the HTTP/TLS connection phase, suggesting potential network connectivity issues or API endpoint accessibility problems
  • The error happens consistently when trying to interact with the agent through the web UI or CLI
  • Virtual environment is properly activated and all dependencies are installed

The issue appears to be related to network connectivity or TLS handshake problems when the ADK tries to establish a connection with the Google AI API servers, rather than an authentication or configuration issue.

Full Error Stack Trace

2025-08-18 10:56:52,112 - ERROR - adk_web_server.py:881 - Error in event_generator: 
Traceback (most recent call last):
  File "/Users/vpsiddhant/src/cursor-test/.venv/lib/python3.13/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions
    yield
  File "/Users/vpsiddhant/src/cursor-test/.venv/lib/python3.13/site-packages/httpx/_transports/default.py", line 394, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "/Users/vpsiddhant/src/cursor-test/.venv/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request
    raise exc from None
  File "/Users/vpsiddhant/src/cursor-test/.venv/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 236, in handle_async_request
    response = await connection.handle_async_request(
  File "/Users/vpsiddhant/src/cursor-test/.venv/lib/python3.13/site-packages/httpcore/_async/connection.py", line 101, in handle_async_request
    raise exc
  File "/Users/vpsiddhant/src/cursor-test/.venv/lib/python3.13/site-packages/httpcore/_async/connection.py", line 78, in handle_async_request
    stream = await self._connect(request)
  File "/Users/vpsiddhant/src/cursor-test/.venv/lib/python3.13/site-packages/httpcore/_async/connection.py", line 156, in _connect
    stream = await stream.start_tls(**kwargs)
  File "/Users/vpsiddhant/src/cursor-test/.venv/lib/python3.13/site-packages/httpcore/_backends/anyio.py", line 67, in start_tls
    with map_exceptions(exc_map):
  File "/opt/homebrew/Cellar/python@3.13/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/contextlib.py", line 162, in __exit__
    self.gen.throw(value)
  File "/Users/vpsiddhant/src/cursor-test/.venv/lib/python3.13/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError

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

Traceback (most recent call last):
  File "/Users/vpsiddhant/src/cursor-test/.venv/lib/python3.13/site-packages/google/adk/cli/adk_web_server.py", line 871, in event_generator
    async for event in agen:
  ...
  File "/Users/vpsiddhant/src/cursor-test/.venv/lib/python3.13/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError

Metadata

Metadata

Assignees

No one assigned

    Labels

    web[Component] This issue will be transferred to adk-web

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions