{"record":{"id":"f2c6d45016cf62dd","repo":"mono/mono","slug":"attach-failed-to-bind-ipc-socket-s-s","errorCode":null,"errorMessage":"attach: failed to bind IPC socket '%s': %s\n","messagePattern":"attach: failed to bind IPC socket '(.+?)': (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"mono/metadata/attach.c","lineNumber":424,"sourceCode":"\t\t\t}\n\t\t} else {\n\t\t\tperror (\"attach: mkdir () failed\");\n\t\t\treturn;\n\t\t}\n\t}\n\n\tfilename = g_strdup_printf (\"%s/.mono-%\" PRIdMAX, directory, (intmax_t) getpid ());\n\tunlink (filename);\n\n\t/* Bind a name to the socket.   */\n\tname.sun_family = AF_UNIX;\n\tstrcpy (name.sun_path, filename);\n\n\tsize = (offsetof (struct sockaddr_un, sun_path)\n\t\t\t+ strlen (name.sun_path) + 1);\n\n\tif (bind (sock, (struct sockaddr *) &name, size) < 0) {\n\t\tfprintf (stderr, \"attach: failed to bind IPC socket '%s': %s\\n\", filename, strerror (errno));\n\t\tclose (sock);\n\t\treturn;\n\t}\n\n\t/* Set permissions */\n\tres = chmod (filename, S_IRUSR | S_IWUSR);\n\tif (res != 0) {\n\t\tperror (\"attach: failed to set permissions on IPC socket\");\n\t\tclose (sock);\n\t\tunlink (filename);\n\t\treturn;\n\t}\n\n\tres = listen (sock, 16);\n\tif (res != 0) {\n\t\tfprintf (stderr, \"attach: listen () failed: %s\\n\", strerror (errno));\n\t\texit (1);\n\t}","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mono/metadata/attach.c#L406-L442","documentation":"After building the UNIX socket path /tmp/mono-<user>/.mono-<pid>, ipc_connect calls bind(); on failure it prints the path and strerror(errno), closes the socket fd, and returns (does not exit). The IPC listener is not established.","triggerScenarios":"bind() fails: pathname too long for sun_path, another process holds the path, the path resides on a filesystem that does not support sockets, or EDQUOT/ENOSPC.","commonSituations":"Very long username inflating the path beyond sun_path limit; a stale socket file not removed; bind into /tmp mounted noexec/nosocket; quota exhaustion.","solutions":["Remove any stale socket file at the reported path: `rm <path>`.","If the path is too long (long username/PID), shorten the user name or use a shorter TMP base if configurable.","Check errno text: EADDRINUSE (path taken), ENAMETOOLONG (sun_path limit), EACCES (perms).","Confirm /tmp supports UNIX sockets (not a strange FUSE/no-dev mount)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-clean stale socket files and check path length:\n//   sock=\"/tmp/mono-$USER/.mono-$$\"\n//   [ -e \"$sock\" ] && rm -f \"$sock\"\n//   [ ${#sock} -ge 108 ] && echo \"socket path too long; shorten username\" && exit 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remove stale .mono-<pid> socket files in process startup hooks.","Keep usernames short to avoid sun_path truncation."],"tags":["mono","attach","ipc","socket","bind"],"backgroundTag":null,"analyzedSha":"0f53e9e151d92944cacab3e24ac359410c606df6","analyzedAt":"2026-08-13T18:54:37.190Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}