M
Mastra2w ago
Karl

Mastra in Google Cloud Run

I am having a difficult time using Mastra in GCP Cloud Run. I have enabled CORS in the most permissive way possible. I connected Mastra Cloud with my Mastra server in Cloud Run, and I can see the agents and workflows and everything, but when I tried to chat with an agent, I see some network error message showing up. Upon refresh, I see my message 4 times, and Mastra server replied 4 times. Inspecting the networks, I see 4 POST requests which resulted in CORS error, but I think it is not CORS related. The endpoint I am invoking is https://mastra-ai-service-***.europe-*****.run.app/api/agents/weatherAgent/stream, and I see in Bruno/Postman 502 Bad Gateway: upstream connect error or disconnect/reset before headers. reset reason: protocol error. Thus, this is not directly a CORS problem. Then, I inspected the GCP Cloud Run log, and I only see
{
httpRequest: {14}
insertId: "***"
labels: {3}
logName: "projects/***/logs/run.googleapis.com%2Frequests"
payload: "payloadNotSet"
receiveLocation: "europe-*****"
receiveTimestamp: "2025-10-31T11:45:18.930954731Z"
resource: {2}
severity: "ERROR"
spanId: "***"
timestamp: "2025-10-31T11:45:18.879029Z"
trace: "projects/***/traces/***"
traceSampled: true
}
{
httpRequest: {14}
insertId: "***"
labels: {3}
logName: "projects/***/logs/run.googleapis.com%2Frequests"
payload: "payloadNotSet"
receiveLocation: "europe-*****"
receiveTimestamp: "2025-10-31T11:45:18.930954731Z"
resource: {2}
severity: "ERROR"
spanId: "***"
timestamp: "2025-10-31T11:45:18.879029Z"
trace: "projects/***/traces/***"
traceSampled: true
}
So there is nothing useful in the log, even though I have set the PinoLogger to DEBUG level. Has anyone successfully run Mastra in Google Cloud Run? Did you connect Mastra cloud to it? Please share.
2 Replies
Mastra Triager
GitHub
[DISCORD:1433785136364781720] Mastra in Google Cloud Run · Issue #...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1433785136364781720 I am having a difficult time using Mastra in GCP Cloud Run. I have enabled CORS in the...
_roamin_
_roamin_2w ago
Hey @Karl ! Are you able to interact with your Mastra API endpoint outside of Studio?

Did you find this page helpful?