Hmbown/CodeWhale · error · MachineError
Could not reach the Codewhale service
Error message
Could not reach the Codewhale service: {} What it means
send_with_retry wraps cloud transport calls; when transport.execute returns Err (no HTTP response at all — DNS failure, refused connection, TLS error, timeout at the transport layer), it builds a transport MachineError with this message. Idempotent requests are retried with backoff before the error surfaces.
Solutions
- Check network connectivity and that the Codewhale service URL is correct
- Verify the service is up (status page or health endpoint)
- Check proxy/VPN/firewall settings and TLS certificates
- Retry later if it is a transient outage — idempotent calls already retry with backoff
Example fix
// ensure base URL is reachable before calling
let url = std::env::var("CODEWHALE_SERVICE_URL")?;
reqwest::get(format!("{url}/health")).await
.context("Codewhale service unreachable — check URL/network")?; Defensive patterns
Strategy: retry
Validate before calling
// pre-flight reachability check
reqwest::get(format!("{base}/health")).await.map_err(|e| format!("service unreachable: {e}"))?; Try / catch
match send_with_retry(...) {
Ok(resp) => resp,
Err(e) if e.to_string().contains("Could not reach the Codewhale service") => {
// transport-layer failure: check connectivity, then retry or fail gracefully
eprintln!("offline or wrong service URL; retry later");
default_value
}
Err(e) => return Err(e),
} Prevention
- Check network/VPN before cloud operations
- Confirm the service base URL configuration
- Rely on idempotent-retry semantics; make requests idempotent where possible
- Monitor service status during outages
When it happens
Trigger: Any cloud API call (e.g. get_json) when the machine cannot connect to the Codewhale service: service down, wrong base URL, DNS failure, firewall, TLS handshake failure, or local network outage.
Common situations: Offline development; corporate proxies blocking the endpoint; mistyped CODEWHALE service URL; service outage during `codewhale account` operations.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- building bundle fetch client failed
- bundle fetch failed with HTTP status
- bundle fetch request failed
- bundle redirects may not change URL scheme
- Cloud agent create failed
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/70af930601ec665b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/cloud/machine.rs:719
retry: Retry,
sleeper: &mut dyn FnMut(Duration),
build: impl Fn() -> CloudRequest,
) -> Result<CloudResponse> {
let max_attempts = if retry == Retry::Idempotent {
MAX_ATTEMPTS
} else {
1
};
let mut attempt = 1;
loop {
let (error, retry_after) = match transport.execute(build()) {
Ok(response) if (200..300).contains(&response.status) => return Ok(response),
Ok(response) => {
let retry_after = response.retry_after;
(classify(&response), retry_after)
}
Err(err) => (
MachineError::transport(format!(
"Could not reach the Codewhale service: {}",
printable(&err.to_string())
)),
None,
),
};
if !error.retryable || attempt >= max_attempts {
return Err(anyhow::Error::new(error));
}
sleeper(backoff_delay(attempt, retry_after));
attempt += 1;
}
}
fn decode_json<R: serde::de::DeserializeOwned>(response: CloudResponse) -> Result<R> {
serde_json::from_slice(&response.body)
.context("The Codewhale service returned an invalid JSON response")
}View on GitHub (pinned to 73e0f67d83)