CloudRun A2A request failed: HTTP Error 503: Network communication error: All connection attempts failed
I was able to publish GCR for remote agent via uvicorn agent:a2a_app --host localhost --port 8001 ,
testing A2A, but im getting "A2A request failed: HTTP Error 503: Network communication error: All connection attempts failed ",
during running in local , I can access the agent card in https://adk-xx-xx-xxxxx.us-central1.run.app/.well-known/agent-card.json and nolog error in my GCR, what could be the problem?
In the client, try the following code:
client = A2AClient(http_client, url=AGENT_URL)
in which AGENT_URL is your deployed service, looks like: https://XYZ.us-central1.run.app (Only that for the agent url, not including the rest /.well-know...)
I have a working A2A agent repository here, you can have a look:
https://github.com/tsnguyenducphuong/media-agency
In the client, try the following code:
client = A2AClient(http_client, url=AGENT_URL)
in which AGENT_URL is your deployed service, looks like: https://XYZ.us-central1.run.app (Only that for the agent url, not including the rest /.well-know...)
I have a working A2A agent repository here, you can have a look:
https://github.com/tsnguyenducphuong/media-agency
are u using adk a2a? I have this example code check prime number as remote
import random
from google.adk.agents.llm_agent import Agent from google.adk.agents.remote_a2a_agent import AGENT_CARD_WELL_KNOWN_PATH from google.adk.agents.remote_a2a_agent import RemoteA2aAgent from google.adk.tools.example_tool import ExampleTool from google.genai import types
--- Roll Die Sub-Agent ---
def roll_die(sides: int) -> int: """Roll a die and return the rolled result.""" return random.randint(1, sides)
roll_agent = Agent( name="roll_agent", description="Handles rolling dice of different sizes.", instruction=""" You are responsible for rolling dice based on the user's request. When asked to roll a die, you must call the roll_die tool with the number of sides as an integer. """, tools=[roll_die], generate_content_config=types.GenerateContentConfig( safety_settings=[ types.SafetySetting( # avoid false alarm about rolling dice. category=types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, threshold=types.HarmBlockThreshold.OFF, ), ] ), )
example_tool = ExampleTool([ { "input": { "role": "user", "parts": [{"text": "Roll a 6-sided die."}], }, "output": [ {"role": "model", "parts": [{"text": "I rolled a 4 for you."}]} ], }, { "input": { "role": "user", "parts": [{"text": "Is 7 a prime number?"}], }, "output": [{ "role": "model", "parts": [{"text": "Yes, 7 is a prime number."}], }], }, { "input": { "role": "user", "parts": [{"text": "Roll a 10-sided die and check if it's prime."}], }, "output": [ { "role": "model", "parts": [{"text": "I rolled an 8 for you."}], }, { "role": "model", "parts": [{"text": "8 is not a prime number."}], }, ], }, ])
prime_agent = RemoteA2aAgent( name="prime_agent", description="Agent that handles checking if numbers are prime.", agent_card=( f"https://adk-xxx-service-xxxx.us-central1.run.app/.well-known/agent-card.json" ), )
root_agent = Agent( model="gemini-2.0-flash", name="root_agent", instruction=""" You are a helpful assistant that can roll dice and check if numbers are prime. You delegate rolling dice tasks to the roll_agent and prime checking tasks to the prime_agent. Follow these steps: 1. If the user asks to roll a die, delegate to the roll_agent. 2. If the user asks to check primes, delegate to the prime_agent. 3. If the user asks to roll a die and then check if the result is prime, call roll_agent first, then pass the result to prime_agent. Always clarify the results before proceeding. """, global_instruction=( "You are DicePrimeBot, ready to roll dice and check prime numbers." ), sub_agents=[roll_agent, prime_agent], tools=[example_tool],
generate_content_config=types.GenerateContentConfig(
safety_settings=[
types.SafetySetting( # avoid false alarm about rolling dice.
category=types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
threshold=types.HarmBlockThreshold.OFF,
),
]
),
)
in the log I got successfully fetch the Agent card
2025-08-22 11:05:51,910 - INFO - google_llm.py:205 - Response received from the model. 2025-08-22 11:05:51,910 - WARNING - types.py:5440 - Warning: there are non-text parts in the response: ['function_call'], returning concatenated text result from text parts. Check the full candidates.content.parts accessor to get the full model response. 2025-08-22 11:05:52,777 - INFO - _client.py:1740 - HTTP Request: GET https://xxx-xxxx-service-xxxx.us-central1.run.app/.well-known/agent-card.json "HTTP/1.1 200 OK" 2025-08-22 11:05:52,778 - INFO - card_resolver.py:83 - Successfully fetched agent card data from https://adk-agent-service-248711292256.us-central1.run.app/.well-known/agent-card.json: {'capabilities': {}, 'defaultInputModes': ['text/plain'], 'defaultOutputModes': ['text/plain'], 'description': 'check prime agent that can check whether numbers are prime.', 'name': 'check_prime_agent', 'preferredTransport': 'JSONRPC', 'protocolVersion': '0.3.0', 'skills': [{'description': 'check prime agent that can check whether numbers are prime. \n I check whether numbers are prime.\n When checking prime numbers, call the check_prime tool with a list of integers. Be sure to pass in a list of integers. I should never pass in a string.\n I should not rely on the previous history on prime results.\n ', 'id': 'check_prime_agent', 'name': 'model', 'tags': ['llm']}, {'description': 'Check if a given list of numbers are prime.\n\nArgs:\n nums: The list of numbers to check.\n\nReturns:\n A str indicating which number is prime.', 'id': 'check_prime_agent-check_prime', 'name': 'check_prime', 'tags': ['llm', 'tools']}], 'supportsAuthenticatedExtendedCard': False, 'url': 'http://localhost:8080', 'version': '0.0.1'}
I am using a2a-sdk: https://github.com/a2aproject/a2a-samples
Try the previous mentioned code, it should work. In your log, the agent url is http://localhost:8080 That's why it got 503 You can test by at the same time run a local A2A server, even you call the remote server, but in the agent card the agent url return localhost. You can change that by config the host and port when starting A2A server to point to your deployed CloudRun url
I am using a2a-sdk: https://github.com/a2aproject/a2a-samples
Try the previous mentioned code, it should work. In your log, the agent url is http://localhost:8080 That's why it got 503 You can test by at the same time run a local A2A server, even you call the remote server, but in the agent card the agent url return localhost. You can change that by config the host and port when starting A2A server to point to your deployed CloudRun url
okay thanks, got no problem testing in local, now got different error, im testing in local the remote agent that was deployed in GCR ,
the error now is
A2A request failed: HTTP Error 503: Network communication error: All connection attempts failed
what could be the problem?
If you use the example, this file should have the url updated correctly, the sample file point to localhost
https://github.com/google/adk-python/blob/main/contributing/samples/a2a_basic/remote_a2a/check_prime_agent/agent.json
If you use the example, this file should have the url updated correctly, the sample file point to localhost
https://github.com/google/adk-python/blob/main/contributing/samples/a2a_basic/remote_a2a/check_prime_agent/agent.json
I'm testing the remote agent that was from GCR from local
If you use the example, this file should have the url updated correctly, the sample file point to localhost
https://github.com/google/adk-python/blob/main/contributing/samples/a2a_basic/remote_a2a/check_prime_agent/agent.json
I want able to update the url correctly to GCR host https://adk-xxx-service-xxxx.us-central1.run.app, but now im getting error
A2A request failed: HTTP Error 503: Network communication error: [Errno 11001] getaddrinfo failed
Check the GCR log of the deployed service, you will see A2A server is started on which host:port
Then check the Dockerfile if the port is EXPOSE Here is a sample Dockerfile: https://github.com/tsnguyenducphuong/product_description_a2a_server/blob/main/Dockerfile
And sample command with allow unauthenticated
gcloud run deploy product-description-agent
--source ~/product_description_a2a_server
--port=8080
--allow-unauthenticated
--min 1
--region us-central1
--timeout=600
Check the GCR log of the deployed service, you will see A2A server is started on which host:port
Then check the Dockerfile if the port is EXPOSE Here is a sample Dockerfile: https://github.com/tsnguyenducphuong/product_description_a2a_server/blob/main/Dockerfile
And sample command with allow unauthenticated
gcloud run deploy product-description-agent --source ~/product_description_a2a_server --port=8080 --allow-unauthenticated --min 1 --region us-central1 --timeout=600
logs seems normal
INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit) Default STARTUP TCP probe succeeded after 1 attempt for container "adk-agent-service-1" on port 8080.
in my remote started port 8080
in my a2a code
a2a_app = to_a2a(root_agent, port=8080,host="https://xx-xx-service-xx.us-central1.run.app")
here is my docker file
`
FROM python:3.13-slim WORKDIR /app
COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt
RUN adduser --disabled-password --gecos "" myuser &&
chown -R myuser:myuser /appCOPY . .
USER myuser
ENV PATH="/home/myuser/.local/bin:$PATH"
CMD ["uvicorn", "agent:a2a_app", "--host", "0.0.0.0", "--port", "8080"]
`
will try to EXPOSE 8080
EXPOSE 8080 wont work :(
In the client, try the following code:
client = A2AClient(http_client, url=AGENT_URL)
in which AGENT_URL is your deployed service, looks like: https://XYZ.us-central1.run.app (Only that for the agent url, not including the rest /.well-know...)
I have a working A2A agent repository here, you can have a look:
https://github.com/tsnguyenducphuong/media-agency
the GCR actually work using A2A sdk , so A2A agent will be as Tool
Any solution to this problem?
I'm experiencing the same error when deploying to GKE.
Even with DNS, I can return the agent card.
However, when sending a request, I receive the error
ERROR - remote_a2a_agent.py:505 - A2A request failed: HTTP Error 503: Network communication error: All connection attempts failed.
I use it to expose the agent
a2a_app = to_a2a(root_agent, port=8080)
uvicorn.run(a2a_app, host="0.0.0.0", port=8080)
and I use it to consume
my_a2a_agent = RemoteA2aAgent(
name='my_a2a_agent ',
description="Agent A2A",
agent_card=(f"https://my_domain/discovery{AGENT_CARD_WELL_KNOWN_PATH}"),
)
is anyone looked into this issue. I am also facing same error.
Hello,
We have version released, it is highly recommended to try our latest version i.e. google-adk ==1.20.0 and see if this resolve your issue.
This issue has been automatically marked as stale because it has not had recent activity for 7 days after a maintainer requested clarification. It will be closed if no further activity occurs within 7 days.
This has been automatically closed because it has been marked as stale for over 7 days.