oven-sh/bun · error · http::Error

UnrequestedUpgrade

UnrequestedUpgrade

Error message

UnrequestedUpgrade

What it means

The server attempted to upgrade the connection to a different protocol (e.g., WebSocket) when no upgrade was requested by the client. This fires when an Upgrade header appears in a response the client did not initiate.

Solutions

  1. Verify the server is not incorrectly sending Upgrade headers for normal requests
  2. Use the WebSocket client API if an upgraded connection is actually intended
  3. Check for misconfigured proxies that inject upgrade responses
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/http/error.rs:54 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/eea044017ffa6c2c. Report an issue: GitHub.

Appendix: source

Thrown at src/http/error.rs:54

    #[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")]
    RequestBodyNotReusable,
    #[error("UnsupportedRedirectProtocol")]
    UnsupportedRedirectProtocol,
    #[error("RedirectURLTooLong")]
    RedirectURLTooLong,
    #[error("RedirectURLInvalid")]
    RedirectURLInvalid,
    #[error("InvalidRedirectURL")]

View on GitHub (pinned to 8c5296ac45)