{"record":{"id":"cf207dacd559d3f4","repo":"crowdsecurity/crowdsec","slug":"w-path-length-exceeds-system-limit-d-d","errorCode":null,"errorMessage":"%w (path length exceeds system limit: %d > %d)","messagePattern":"%w \\(path length exceeds system limit: (.+?) > (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/csnet/socket.go","lineNumber":20,"sourceCode":"\nimport (\n\t\"fmt\"\n\t\"runtime\"\n)\n\n// WrapSockErr wraps the provided error with a possible cause if the unix socket path exceeds\n// a system-specific maximum length. It returns the original error otherwise.\nfunc WrapSockErr(err error, socket string) error {\n\tlimit := 0\n\tswitch runtime.GOOS {\n\tcase \"linux\":\n\t\t// the actual numbers are not exported in Go, so we hardcode them\n\t\tlimit = 108\n\tcase \"freebsd\", \"darwin\", \"openbsd\":\n\t\tlimit = 104\n\t}\n\tif limit > 0 && len(socket) > limit {\n\t\treturn fmt.Errorf(\"%w (path length exceeds system limit: %d > %d)\", err, len(socket), limit)\n\t}\n\treturn err\n}\n","sourceCodeStart":2,"sourceCodeEnd":24,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csnet/socket.go#L2-L24","documentation":"WrapSockErr decorates socket errors with an extra message when the unix socket path exceeds the OS's sun_path limit (108 chars on Linux, 104 on BSD/macOS — Go doesn't export them so they're hardcoded). A too-long socket path fails at bind time with EINVAL/'invalid argument'; this wrapper turns the cryptic error into one that names the length and the limit.","triggerScenarios":"The LAPI unix socket path derived from the configured lapi unix socket dir + filename exceeds the OS limit — e.g. long install prefixes or long docker volume paths used in api.client.insecure_skip_verify / unix socket config.","commonSituations":"CrowdSec installed under a deep path (long --prefix builds), container mounts like /var/lib/.../long-hash-directory/crowdsec.sock, or macOS/FreeBSD installs where the 104-char limit bites even on moderately long paths.","solutions":["Shorten the unix socket path in the config: use a short directory like /run/crowdsec/ or /var/run/ for the socket.","Move the socket dir to a symlinked short path if you cannot relocate the data (bind the socket at a short path).","Reduce the socket filename length if the directory path is already near the limit.","Switch the LAPI client to connect via TCP (host/port) instead of a unix socket when path shortening is impossible."],"exampleFix":"// before (config.yaml)\napi:\n  server:\n    socket: /very/long/deep/install/prefix/with/many/nested/directories/that/exceeds/the/limit/crowdsec.sock\n// after\napi:\n  server:\n    socket: /run/crowdsec/crowdsec.sock","handlingStrategy":"validation","validationCode":"const linuxSunPath = 108\nif len(socketPath) >= linuxSunPath {\n    return fmt.Errorf(\"socket path %q too long (%d >= %d); use a shorter path\", socketPath, len(socketPath), linuxSunPath)\n}","typeGuard":null,"tryCatchPattern":"if err := broker.Listen(); err != nil {\n    if strings.Contains(err.Error(), \"path length exceeds system limit\") {\n        // reconfigure the socket to /run/crowdsec/ or fall back to TCP\n    }\n    return err\n}","preventionTips":["Keep unix socket paths under ~100 characters; prefer /run/crowdsec/.","Beware long docker volume or hash-suffixed mount paths on macOS/BSD (104 limit).","Use TCP listeners instead of unix sockets for deeply nested install prefixes."],"tags":["unix-socket","path","network"],"backgroundTag":"invalid-argument-value","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}