<@ULVA73B9P> httpx.LocalProtocolError: Invalid in...
# ask-community
r
@Marvin httpx.LocalProtocolError: Invalid input ConnectionInputs.RECV_PING in state ConnectionState.CLOSED I am ettign this error can anyone help me with that .
m
thought for 335.6 seconds
Thanks for flagging this. That error usually means an HTTP/2 PING frame was received after the connection had already closed. It’s a known quirk in the httpx/httpcore/h2 stack and typically shows up on long‑lived or reused HTTP/2 connections. Quickest workaround - Disable HTTP/2 for the Prefect API client (use HTTP/1.1 instead): - Via Prefect config (persists in your profile):
Copy code
prefect config set PREFECT_API_ENABLE_HTTP2=false
- Or via environment variable before starting your worker/flow:
Copy code
export PREFECT_API_ENABLE_HTTP2=false
- You can confirm your setting with:
Copy code
prefect config view
If you need to set it in code for a specific client
Copy code
from prefect.client.orchestration import get_client

async def use_api():
    async with get_client(httpx_settings={"http2": False}) as client:
        # make API calls
        ...
Why this helps - The error is specific to HTTP/2 connection state transitions (server sends a PING after the connection has been closed). Using HTTP/1.1 avoids that code path entirely. Additional steps (optional) - Update the HTTP stack in your environment (often resolves edge cases):
Copy code
pip install -U httpx httpcore h2
- If you must keep HTTP/2 enabled, you can try reducing connection reuse (e.g., disabling keep-alive or lowering keep-alive limits) via
httpx_settings
, but disabling HTTP/2 is the simplest and most reliable fix. A few questions to help us tailor a fix - Which Prefect version are you on? (Assuming 3.x unless you say otherwise.) - Prefect Cloud or Prefect Server/self-hosted? - Where is this running (local, Docker, Kubernetes), and is there a proxy/ingress in front of the API? - Does it happen after flows sit idle for a while or randomly during normal operation? - Can you share a slightly larger slice of the stack trace to confirm it’s happening in the Prefect API client? Docs for reference - Prefect settings (including
PREFECT_API_ENABLE_HTTP2
): Settings reference - Prefect client and `get_client(httpx_settings=...)`: Client (orchestration) API