{"record":{"id":"1f832b17e60395f5","repo":"quarkusio/quarkus","slug":"unix-socket-not-supported","errorCode":null,"errorMessage":"Unix socket not supported","messagePattern":"Unix socket not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/graal/MongoClientSubstitutions.java","lineNumber":135,"sourceCode":"    @Substitute\n    private CompressorSubstitute createCompressor(final MongoCompressor mongoCompressor) {\n        throw new UnsupportedOperationException(\"Unsupported compressor in native mode\");\n    }\n}\n\n@TargetClass(UnixSocketChannelStream.class)\n@Delete\nfinal class UnixSocketChannelStreamSubstitution {\n\n}\n\n@TargetClass(ServerAddressHelper.class)\nfinal class ServerAddressHelperSubstitution {\n\n    @Substitute\n    public static ServerAddress createServerAddress(final String host, final int port) {\n        if (host != null && host.endsWith(\".sock\")) {\n            throw new UnsupportedOperationException(\"Unix socket not supported\");\n        } else {\n            return new ServerAddress(host, port);\n        }\n    }\n\n}\n\n//TODO: move to a dedicated jna extension that will simply collect JNA substitutions\n@TargetClass(com.sun.jna.Native.class)\nfinal class JnaNativeSubstitutions {\n\n    // This method can trick GraalVM into thinking that Classloader#findLibrary is getting called\n    @Substitute\n    public static String getWebStartLibraryPath(final String libName) {\n        return null;\n    }\n}\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/graal/MongoClientSubstitutions.java#L117-L153","documentation":"Quarkus's native-mode substitution of ServerAddressHelper.createServerAddress rejects Unix domain socket addresses (.sock) because unix socket channels are deleted in native images (UnixSocketChannelStream is @Delete'd). It throws UnsupportedOperationException when the host ends with '.sock', otherwise builds a normal TCP ServerAddress.","triggerScenarios":"Configuring a MongoDB connection string like mongodb://%2Ftmp%2Fmongodb-27017.sock or a host ending in .sock while running a native executable.","commonSituations":"Local MongoDB deployed over a unix socket (common in Linux dev/containers) works in JVM mode, then fails in native mode; quoting a URI copied from a socket-based mongod setup.","solutions":["Connect via TCP instead: use localhost:27017 (drop the .sock host)","Expose MongoDB on a TCP port in container/dev environments","Use JVM mode if unix socket connectivity is required"],"exampleFix":"// before\nquarkus.mongodb.connection-string=mongodb://%2Ftmp%2Fmongodb-27017.sock\n// after\nquarkus.mongodb.connection-string=mongodb://localhost:27017","handlingStrategy":"validation","validationCode":"String host = UriUtils.extractHost(connectionString);\nif (host != null && host.endsWith(\".sock\") && isNativeImage()) {\n    throw new IllegalStateException(\"Unix socket MongoDB addresses are not supported in native mode\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    mongoClient = MongoClients.create(connStr);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"Unix socket\")) {\n        connStr = tcpFallback(connStr); // swap .sock host for localhost:port\n    } else throw e;\n}","preventionTips":["Use TCP endpoints for MongoDB in native deployments","Keep unix-socket-only configs in JVM-only profiles","Verify container/service discovery exposes a TCP port, not just a socket file"],"tags":["mongodb","unix-socket","native-image","graal"],"backgroundTag":"mongodb-native-image-unsupported-feature","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}