oven-sh/bun · error · TypeError

ConnectionRefused

ConnectionRefused

Error message

ConnectionRefused

What it means

Sentinel variant of the HTTP client Error enum: the TCP connection attempt to the target host:port was refused by the remote (nothing listening, or firewall reject). Surfaced by fetch/HTTP client code after connect() fails with ECONNREFUSED; consumers map it to network error codes.

Solutions

  1. Verify the server is running and listening on the expected port
  2. Check firewall rules and security groups
  3. Confirm the host and port in the URL are correct
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/http/error.rs:46 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/88af593b1cbd129b. Report an issue: GitHub.

Appendix: source

Thrown at src/http/error.rs:46

    #[error("HTTP2CompressionError")]
    HTTP2CompressionError,
    #[error("Timeout")]
    Timeout,
    #[error("AbortedBeforeConnecting")]
    AbortedBeforeConnecting,
    #[error("InvalidURL")]
    InvalidURL,
    #[error("ERR_TLS_CERT_ALTNAME_INVALID")]
    ERR_TLS_CERT_ALTNAME_INVALID,
    #[error("ClientAborted")]
    ClientAborted,
    #[error("HTTP2Unsupported")]
    HTTP2Unsupported,
    #[error("ConnectionClosed")]
    ConnectionClosed,
    #[error("DNSResolveFailed")]
    DNSResolveFailed,
    #[error("ConnectionRefused")]
    ConnectionRefused,
    #[error("TooManyRedirects")]
    TooManyRedirects,
    #[error("HTTP3Unsupported")]
    HTTP3Unsupported,
    #[error("ResponseHeadersTooLarge")]
    ResponseHeadersTooLarge,
    #[error("UnrequestedUpgrade")]
    UnrequestedUpgrade,
    #[error("UnexpectedData")]
    UnexpectedData,
    #[error("InvalidHTTPResponse")]
    InvalidHTTPResponse,
    #[error("InvalidContentLength")]
    InvalidContentLength,
    #[error("UnsupportedTransferEncoding")]
    UnsupportedTransferEncoding,
    #[error("RequestBodyNotReusable")]

View on GitHub (pinned to 8c5296ac45)