{"record":{"id":"b10338da0f5476a3","repo":"redis/node-redis","slug":"invalid-protocol","errorCode":null,"errorMessage":"Invalid protocol","messagePattern":"Invalid protocol","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/client/lib/client/index.ts","lineNumber":493,"sourceCode":"      return RedisClient.#parseUnixURL(url);\n    }\n\n    // https://www.iana.org/assignments/uri-schemes/prov/redis\n    const { hostname, port, protocol, username, password, pathname } = new URL(url),\n      parsed: AnyRedisClientOptions & {\n        socket: Exclude<AnyRedisClientOptions['socket'], undefined> & {\n          tls: boolean\n        }\n      } = {\n        socket: {\n          // Use net.SocketAddress.parse() once supported.\n          host: hostname.replace(/^\\[([0-9a-f:]+)\\]$/, '$1'),\n          tls: false\n        }\n      };\n\n    if (protocol !== 'redis:' && protocol !== 'rediss:') {\n      throw new TypeError('Invalid protocol');\n    }\n\n    parsed.socket.tls = protocol === 'rediss:';\n\n    if (port) {\n      (parsed.socket as TcpSocketConnectOpts).port = Number(port);\n    }\n\n    if (username) {\n      parsed.username = decodeURIComponent(username);\n    }\n\n    if (password) {\n      parsed.password = decodeURIComponent(password);\n    }\n\n    if (username || password) {\n      parsed.credentialsProvider = {","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/redis/node-redis/blob/90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58/packages/client/lib/client/index.ts#L475-L511","documentation":"RedisClient.parseURL only accepts the redis: and rediss: schemes. WHATWG URL parses the input first; any other protocol (http:, https:, tcp:, empty, or a bare host that yields no protocol) reaches the protocol check and throws.","triggerScenarios":"Passing 'http://host:6379', 'tcp://host:6379', 'host:6379' (no scheme), or any non-Redis URL to createClient({ url }).","commonSituations":"Misconfigured environment variable; using a service-discovery URL of the wrong scheme; copy-pasting a connection string from a different system (Postgres/HTTP).","solutions":["Use the redis:// or rediss:// scheme.","If you only have host/port, pass them via socket.host and socket.port instead of url."],"exampleFix":"// before\ncreateClient({ url: 'http://redis:6379' });\n\n// after\ncreateClient({ url: 'redis://redis:6379' });\n// or\ncreateClient({ socket: { host: 'redis', port: 6379 } });","handlingStrategy":"validation","validationCode":"function assertRedisUrl(url) {\n  if (!/^redis(s?):\\/\\/.+/.test(url)) {\n    throw new TypeError(`Expected redis:// or rediss:// URL, got ${JSON.stringify(url)}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the URL scheme at config load, before passing it to createClient.","Keep connection strings in a single config source (env var).","If you only have host/port, pass them via socket instead of url."],"tags":["url","config","validation"],"backgroundTag":null,"analyzedSha":"90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58","analyzedAt":"2026-08-11T15:37:21.243Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}