{"record":{"id":"3f0313d1c293ac4d","repo":"transact-rs/sqlx","slug":"one-of-the-runtime-native-tls-or-runtime-ru","errorCode":null,"errorMessage":"one of the `runtime-*-native-tls` or `runtime-*-rustls` features must be enabled","messagePattern":"one of the `runtime-\\*-native-tls` or `runtime-\\*-rustls` features must be enabled","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sqlx-core/src/net/tls/mod.rs","lineNumber":86,"sourceCode":"#[cfg(feature = \"_tls-native-tls\")]\npub use self::tls_native_tls::NativeTlsConnector as TlsConnector;\n#[cfg(all(feature = \"_tls-rustls\", not(feature = \"_tls-native-tls\")))]\npub use self::tls_rustls::RustlsConnector as TlsConnector;\n#[cfg(not(any(feature = \"_tls-native-tls\", feature = \"_tls-rustls\")))]\n#[derive(Debug, Clone)]\npub struct TlsConnector(std::convert::Infallible);\n\npub async fn connector(config: TlsConfig<'_>) -> crate::Result<TlsConnector> {\n    #[cfg(feature = \"_tls-native-tls\")]\n    return tls_native_tls::connector(config).await;\n\n    #[cfg(all(feature = \"_tls-rustls\", not(feature = \"_tls-native-tls\")))]\n    return tls_rustls::connector(config).await;\n\n    #[cfg(not(any(feature = \"_tls-native-tls\", feature = \"_tls-rustls\")))]\n    {\n        _ = config;\n        panic!(\"one of the `runtime-*-native-tls` or `runtime-*-rustls` features must be enabled\")\n    }\n}\n\npub async fn handshake<S, Ws>(\n    socket: S,\n    hostname: &str,\n    connector: &TlsConnector,\n    with_socket: Ws,\n) -> crate::Result<Ws::Output>\nwhere\n    S: Socket,\n    Ws: WithSocket,\n{\n    #[cfg(feature = \"_tls-native-tls\")]\n    return Ok(with_socket\n        .with_socket(tls_native_tls::handshake(socket, hostname, connector).await?)\n        .await);\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/transact-rs/sqlx/blob/03af8bcc5711a1935580a54bea249c219a0c217d/sqlx-core/src/net/tls/mod.rs#L68-L104","documentation":"sqlx's TLS connector() in sqlx-core/src/net/tls/mod.rs panics at runtime when a TLS connection is requested but the crate was compiled without any TLS backend feature. sqlx requires exactly one TLS implementation, selected via `runtime-*-native-tls` or `runtime-*-rustls` feature combinations; with neither `_tls-native-tls` nor `_tls-rustls` enabled, there is no connector to build.","triggerScenarios":"Calling `sqlx::any::connect` / `PgPool::connect` etc. with a `postgres://...?sslmode=require` (or default-TLS) URL while the Cargo.toml enables only a runtime feature (e.g. `runtime-tokio`) without any `-native-tls`/`-rustls` suffix.","commonSituations":"Fresh project where the developer added `sqlx = { version = \"...\", features = [\"runtime-tokio\", \"postgres\"] }` and forgot the TLS feature; Docker release builds that trimmed features; upgrading sqlx and old feature names no longer mapping to TLS backends.","solutions":["Enable a rustls-based combo: `sqlx = { features = [\"runtime-tokio-rustls\", \"postgres\"] }`.","Or enable native-tls: `features = [\"runtime-tokio-native-tls\", \"postgres\"]`.","Verify with `cargo tree -e features` (or `cargo metadata`) that one `_tls-*` feature is actually active; watch for other crates disabling default features and re-enabling only a bare runtime feature.","If TLS is genuinely not needed, ensure the connection URL uses `sslmode=disable` so connector() is never invoked — but enabling a TLS feature is still the robust fix."],"exampleFix":"// before (Cargo.toml)\nsqlx = { version = \"0.8\", features = [\"runtime-tokio\", \"postgres\"] }\n\n// after\nsqlx = { version = \"0.8\", features = [\"runtime-tokio-rustls\", \"postgres\"] }","handlingStrategy":"validation","validationCode":"// Verify a TLS backend is enabled at build time:\n// Cargo.toml\n[features]\ndefault = [\"runtime-tokio-rustls\"]\n// or assert in main.rs before connecting:\n#[cfg(not(any(feature = \"runtime-tokio-rustls\", feature = \"runtime-tokio-native-tls\")))]\ncompile_error!(\"select a TLS runtime feature\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair runtime features with -rustls or -native-tls","Check `cargo tree -e features | grep _tls` after dependency changes","Centralize the sqlx dependency in one workspace crate so features are unified"],"tags":["tls","configuration","feature-flags","sqlx"],"backgroundTag":"missing-tls-feature","analyzedSha":"03af8bcc5711a1935580a54bea249c219a0c217d","analyzedAt":"2026-09-03T15:01:28.752Z","contentChangedAt":"2026-09-03T15:01:28.752Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}