{"record":{"id":"ea1f8b5d16729022","repo":"windmill-labs/windmill","slug":"connection-error-err-instanceof-error-err-mes","errorCode":null,"errorMessage":"connection error: ${err instanceof Error ? err.message : err}","messagePattern":"connection error: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/datatable/serve.ts","lineNumber":102,"sourceCode":"  const port =\n    opts.port ??\n    (await (getPort as any).default({\n      port: (getPort as any).portNumbers(\n        DEFAULT_PORT_RANGE_START,\n        DEFAULT_PORT_RANGE_END,\n      ),\n    }));\n\n  const password = opts.password ?? randomBytes(12).toString(\"hex\");\n  const preHashedPassword = await createPreHashedPassword(\n    DEFAULT_USER,\n    password,\n  );\n\n  const server = createServer((socket) => {\n    handleConnection(socket, workspace.workspaceId, preHashedPassword)\n      .catch((err) => {\n        log.warn(\n          colors.yellow(\n            `connection error: ${err instanceof Error ? err.message : err}`,\n          ),\n        );\n        try {\n          socket.destroy();\n        } catch {\n          // ignore\n        }\n      });\n  });\n\n  server.on(\"error\", (err) => {\n    log.error(`server error: ${err.message}`);\n    process.exitCode = 1;\n  });\n\n  await new Promise<void>((resolve) => server.listen(port, host, () => resolve()));","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/datatable/serve.ts#L84-L120","documentation":"Warning from `wmill datatable serve`, which runs a local Postgres-wire-compatible server that proxies datatable queries to a Windmill workspace. For each accepted TCP connection it runs handleConnection; if that per-connection handler rejects (authentication failure, malformed startup packet, internal error while proxying a query), the server logs `connection error: <message>` and destroys the socket, keeping the server alive for other clients.","triggerScenarios":"A client connects to the `wmill datatable serve` port and handleConnection rejects: wrong password supplied by the client (preHashedPassword mismatch), unsupported/broken protocol handshake from the client, or an error talking to the Windmill API for that connection (e.g. workspace request failed mid-session).","commonSituations":"Pointing psql/DBeaver/Grafana at the serve endpoint with the wrong password; a health-check or port scanner opening raw TCP connections that send garbage bytes; network drop between CLI and Windmill backend while a query is in flight; connecting with a Postgres driver feature (e.g. specific auth modes) the proxy doesn't implement.","solutions":["Check the credentials passed to the client: the password must match the one given to `wmill datatable serve --password ...` (or the prompt); re-run the client with the correct password.","Verify the workspace/backend is healthy: run any `wmill` command against the same workspace; if those also fail, fix backend connectivity/auth and restart `wmill datatable serve`.","Capture the full warning on the server side; a malformed-packet error usually means a non-Postgres client (scanner, health probe) hit the port and can be ignored.","Confirm the client speaks the Postgres wire protocol and start with a simple `psql -h localhost -p <port> -U <user> <datatable>` query to rule out driver-specific handshake features."],"exampleFix":"// before: client connecting without matching password\npsql postgres://user:wrongpass@localhost:5432/mytable\n// after\npsql postgres://user:<the-password-passed-to-serve>@localhost:5432/mytable","handlingStrategy":"validation","validationCode":"// before connecting a client, verify credentials and port reachability\nconst client = new Client({ host: 'localhost', port: SERVE_PORT, user, password });\nawait client.connect().catch((e) => { console.error('Pre-check failed:', e.message); process.exit(1); });\nawait client.end();","typeGuard":"function isConnectionError(e: unknown): e is Error {\n  return e instanceof Error && /connection error|password|authentication/i.test(e.message);\n}","tryCatchPattern":"client.on('error', (err) => {\n  if (/password authentication|auth/i.test(err.message)) {\n    console.error('Wrong password: match the one passed to `wmill datatable serve`.');\n  } else {\n    console.error('Query/connection failed:', err.message);\n  }\n  // reconnect with backoff for transient network errors\n});","preventionTips":["Pass the exact password given to `wmill datatable serve` to every connecting client.","Use a real Postgres-protocol client (psql, standard drivers); avoid health probes sending non-protocol bytes to the port.","Keep the CLI-to-backend network stable; long-running serve sessions drop on network changes/VPN resets.","Check `wmill` commands work against the same workspace first to isolate serve-specific vs. backend-wide failures."],"tags":["network","postgres-wire","authentication","server","cli"],"backgroundTag":"connection-error","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}