{"record":{"id":"49ca43dce583178a","repo":"transact-rs/sqlx","slug":"unix-domain-sockets-are-not-supported-on-this-plat","errorCode":null,"errorMessage":"Unix domain sockets are not supported on this platform","messagePattern":"Unix domain sockets are not supported on this platform","errorType":"exception","errorClass":"io::Error (Unsupported)","httpStatus":null,"severity":"error","filePath":"sqlx-core/src/net/socket/mod.rs","lineNumber":293,"sourceCode":"        cfg_if! {\n            if #[cfg(feature = \"_rt-async-io\")] {\n                use async_io::Async;\n                use std::os::unix::net::UnixStream;\n\n                let stream = Async::<UnixStream>::connect(path).await?;\n\n                Ok(with_socket.with_socket(stream).await)\n            } else {\n                crate::rt::missing_rt((path, with_socket))\n            }\n        }\n    }\n\n    #[cfg(not(unix))]\n    {\n        drop((path, with_socket));\n\n        Err(io::Error::new(\n            io::ErrorKind::Unsupported,\n            \"Unix domain sockets are not supported on this platform\",\n        )\n        .into())\n    }\n}\n","sourceCodeStart":275,"sourceCodeEnd":300,"githubUrl":"https://github.com/transact-rs/sqlx/blob/03af8bcc5711a1935580a54bea249c219a0c217d/sqlx-core/src/net/socket/mod.rs#L275-L300","documentation":"`connect_uds` connects to a Unix domain socket path. On platforms compiled without Unix socket support (`#[cfg(not(unix))]`), it returns an `io::ErrorKind::Unsupported` error wrapped by sqlx. The library does not emulate UDS on non-Unix platforms.","triggerScenarios":"Using a connection string with a Unix socket path (e.g. `postgres:///db?host=/var/run/postgresql` or `mysql://user@/db?socket=/tmp/mysql.sock`) while compiling/running on Windows or other non-unix targets.","commonSituations":"Config built for Linux deployed to Windows; shared DATABASE_URL across developer machines with mixed OSes; cross-compiling a service for a non-unix target while the config points at a socket file.","solutions":["Use TCP (host/port) connection options instead of a Unix socket path on non-unix platforms","Make the socket-based config conditional on target OS (cfg or env-based config)","Compile for a unix target if UDS is a hard requirement"],"exampleFix":"// before (fails on Windows)\nlet opts = PgConnectOptions::new().socket(\"/var/run/postgresql\");\n// after\n#[cfg(unix)]\nlet opts = PgConnectOptions::new().socket(\"/var/run/postgresql\");\n#[cfg(not(unix))]\nlet opts = PgConnectOptions::new().host(\"localhost\").port(5432);","handlingStrategy":"fallback","validationCode":"#[cfg(not(unix))]\nlet use_uds = false;\n#[cfg(unix)]\nlet use_uds = std::path::Path::new(\"/var/run/postgresql\").exists();","typeGuard":null,"tryCatchPattern":"match pool.connect().await {\n    Err(e) if e.to_string().contains(\"Unix domain sockets are not supported\") => {\n        // fall back to TCP options\n    }\n    other => other?,\n}","preventionTips":["Gate socket-based config behind #[cfg(unix)] or an OS check at startup","Provide a TCP fallback in configuration for non-unix deployments","Test your app on every target OS you ship to"],"tags":["rust","sqlx","unix-socket","platform","unsupported"],"backgroundTag":"unsupported-platform-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"}