{"record":{"id":"65ad7c32e7e21fa1","repo":"hashicorp/nomad","slug":"unable-to-remove-existing-unix-socket-for-consul-g","errorCode":null,"errorMessage":"unable to remove existing unix socket for Consul gRPC endpoint: %v","messagePattern":"unable to remove existing unix socket for Consul gRPC endpoint: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/consul_grpc_sock_hook.go","lineNumber":283,"sourceCode":"\t\t\treturn fmt.Errorf(\"unable to parse address template %q: %v\", destAddr, err)\n\t\t}\n\t\tdestAddr = ipStr\n\t}\n\n\tsocketFile := allocdir.AllocGRPCSocket\n\tif p.config.Name != structs.ConsulDefaultCluster && p.config.Name != \"\" {\n\t\tsocketFile = filepath.Join(allocdir.SharedAllocName, allocdir.TmpDirName,\n\t\t\t\"consul_\"+p.config.Name+\"_grpc.sock\")\n\t}\n\thostGRPCSocketPath := filepath.Join(p.allocDir.AllocDirPath(), socketFile)\n\n\t// if the socket already exists we'll try to remove it, but if not then any\n\t// other errors will bubble up to the caller here or when we try to listen\n\t_, err := os.Stat(hostGRPCSocketPath)\n\tif err == nil {\n\t\terr := os.Remove(hostGRPCSocketPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\n\t\t\t\t\"unable to remove existing unix socket for Consul gRPC endpoint: %v\", err)\n\t\t}\n\t}\n\n\tlistener, err := net.Listen(\"unix\", hostGRPCSocketPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to create unix socket for Consul gRPC endpoint: %v\", err)\n\t}\n\n\t// The gRPC socket should be usable by all users in case a task is\n\t// running as an unprivileged user.  Unix does not allow setting domain\n\t// socket permissions when creating the file, so we must manually call\n\t// chmod afterwards.\n\t// https://github.com/golang/go/issues/11822\n\tif err := os.Chmod(hostGRPCSocketPath, os.ModePerm); err != nil {\n\t\treturn fmt.Errorf(\"unable to set permissions on unix socket for Consul gRPC endpoint: %v\", err)\n\t}\n","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/consul_grpc_sock_hook.go#L265-L301","documentation":"Before listening on the host unix socket for the Consul gRPC endpoint, the hook removes any pre-existing socket file; os.Remove failed (e.g. permission denied or stale file held elsewhere), so the proxy cannot bind its socket path.","triggerScenarios":"Thrown at client/allocrunner/consul_grpc_sock_hook.go:283 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check permissions on the alloc dir and existing socket file","Remove the stale socket manually as root if needed","Check for another process holding/creating the socket path"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}