{"id":"a35f6014e046f664","repo":"sindresorhus/got","slug":"using-unix-domain-sockets-but-option-enableunixso","errorCode":null,"errorMessage":"Using UNIX domain sockets but option `enableUnixSockets` is not enabled","messagePattern":"Using UNIX domain sockets but option `enableUnixSockets` is not enabled","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"source/core/options.ts","lineNumber":2130,"sourceCode":"\t\t\tis.string(value)\n\t\t\t&& !this.prefixUrl\n\t\t\t&& hasHttpProtocolWithoutSlashes(valueString)\n\t\t) {\n\t\t\tthrow new Error('`url` protocol must be followed by `//`');\n\t\t}\n\n\t\t// Detect if URL is already absolute.\n\t\tconst isAbsolute = isAbsoluteUrl(value);\n\t\tassertRelativeUrlIfNeeded(this, value);\n\n\t\t// Only concatenate prefixUrl if the URL is relative\n\t\tconst urlString = isAbsolute ? valueString : `${this.prefixUrl as string}${valueString}`;\n\t\tconst url = new URL(urlString);\n\t\tthis.#internals.url = url;\n\t\ttrackStateMutation(this.#trackedStateMutations, 'url');\n\n\t\tif (usesUnixSocket(url) && !this.#internals.enableUnixSockets) {\n\t\t\tthrow new Error('Using UNIX domain sockets but option `enableUnixSockets` is not enabled');\n\t\t}\n\n\t\tif (url.protocol === 'unix:') {\n\t\t\turl.href = `http://unix${url.pathname}${url.search}`;\n\t\t}\n\n\t\tif (url.protocol !== 'http:' && url.protocol !== 'https:') {\n\t\t\tconst error: NodeJS.ErrnoException = new Error(`Unsupported protocol: ${url.protocol}`);\n\t\t\terror.code = 'ERR_UNSUPPORTED_PROTOCOL';\n\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (this.#internals.username) {\n\t\t\turl.username = this.#internals.username;\n\t\t\tthis.#internals.username = '';\n\t\t}\n","sourceCodeStart":2112,"sourceCodeEnd":2148,"githubUrl":"https://github.com/sindresorhus/got/blob/e3924aa1e53a6ca3eb93a43618ce532442a89b40/source/core/options.ts#L2112-L2148","documentation":"Thrown when the resolved URL references a UNIX domain socket (e.g. `http://unix:/var/run/docker.sock:/path`) but the `enableUnixSockets` option is not set to `true`. UNIX socket support is opt-in because it has security and parsing implications, so Got makes you acknowledge it explicitly.","triggerScenarios":"Calling `got('http://unix:/var/run/docker.sock:/info')` without `{enableUnixSockets: true}`, or any URL whose hostname resolves to a socket path while `enableUnixSockets` is at its default of `false`.","commonSituations":"Talking to the Docker API, a local Postgres/Redis socket, or any service over a `.sock` file; copying a curl UNIX-socket URL into Got without enabling the option.","solutions":["Enable the feature: `got(url, {enableUnixSockets: true})` or set it via `got.extend({enableUnixSockets: true})`.","Verify the socket URL uses the `http://unix:<path>:<request-path>` form Got expects.","If you did not intend a socket, fix the URL hostname."],"exampleFix":"// before\nawait got('http://unix:/var/run/docker.sock:/info');\n// after\nawait got('http://unix:/var/run/docker.sock:/info', {enableUnixSockets: true});","handlingStrategy":"validation","validationCode":"function assertUnixSocketEnabled(url, options) {\n  const isUnix = typeof url === 'string' && /unix:/.test(url);\n  if (isUnix && !options?.enableUnixSockets) {\n    throw new Error('Pass {enableUnixSockets: true} for UNIX socket URLs.');\n  }\n}","typeGuard":"function isUnixSocketUrl(v: unknown): boolean {\n  return typeof v === 'string' && /\\/\\/unix:|unix:/.test(v);\n}","tryCatchPattern":null,"preventionTips":["Centralize UNIX-socket calls in a `got.extend({enableUnixSockets: true})` instance.","Document the socket URL format your code expects."],"tags":["options","url","unix-socket","validation","network"],"analyzedSha":"e3924aa1e53a6ca3eb93a43618ce532442a89b40","analyzedAt":"2026-08-03T19:22:24.770Z","schemaVersion":2}