Foundry "cast: error sending request" RPC failure in CI
cast tried to send a JSON-RPC request and the HTTP client could not complete it. The RPC URL is missing, malformed, or the endpoint is unreachable from the runner, so no chain data is returned.
What this error means
A cast call, cast block, or cast send step fails with "Error: error sending request for url (...)" and the run exits non-zero.
Error: error sending request for url (https://): builder error: relative URL without a baseCommon causes
The RPC URL is unset or empty
cast reads --rpc-url or ETH_RPC_URL from an environment variable that is empty in CI, so it sends to an invalid base URL.
The endpoint is unreachable or rejecting requests
A wrong host, a rate-limited provider, or a network restriction stops the request from completing.
How to fix it
Provide a valid RPC URL from a secret
Set the endpoint explicitly and pass it to cast so requests reach a real node.
env:
ETH_RPC_URL: ${{ secrets.ETH_RPC_URL }}
run: cast block latest --rpc-url "$ETH_RPC_URL"Use a local node for chain-independent steps
When the step does not need a live network, run anvil and point cast at it.
anvil &
cast block latest --rpc-url http://127.0.0.1:8545How to prevent it
- Inject RPC URLs through secrets, not committed defaults.
- Use a local anvil node for steps that do not require mainnet data.
- Fail fast with a clear message when the RPC URL is empty.