{"record":{"id":"770433cf9b59a1dd","repo":"coder/code-server","slug":"please-pass-in-a-password-via-the-config-file-or-e","errorCode":null,"errorMessage":"Please pass in a password via the config file or environment variable ($PASSWORD or $HASHED_PASSWORD)","messagePattern":"Please pass in a password via the config file or environment variable \\(\\$PASSWORD or \\$HASHED_PASSWORD\\)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/node/main.ts","lineNumber":137,"sourceCode":"  vscode.end()\n}\n\nexport const runCodeServer = async (\n  args: DefaultedArgs,\n): Promise<{ dispose: Disposable[\"dispose\"]; server: http.Server }> => {\n  logger.info(`code-server ${version} ${commit}`)\n\n  // Load custom strings if provided\n  if (args.i18n) {\n    await loadCustomStrings(args.i18n)\n    logger.info(\"Loaded custom strings\")\n  }\n\n  logger.info(`Using user-data-dir ${args[\"user-data-dir\"]}`)\n  logger.debug(`Using extensions-dir ${args[\"extensions-dir\"]}`)\n\n  if (args.auth === AuthType.Password && !args.password && !args[\"hashed-password\"]) {\n    throw new Error(\n      \"Please pass in a password via the config file or environment variable ($PASSWORD or $HASHED_PASSWORD)\",\n    )\n  }\n\n  const app = await createApp(args)\n  const protocol = args.cert ? \"https\" : \"http\"\n  const serverAddress = ensureAddress(app.server, protocol)\n  const { disposeRoutes, heart } = await register(app, args)\n\n  logger.info(`Using config file ${args.config}`)\n  logger.info(`${protocol.toUpperCase()} server listening on ${serverAddress.toString()}`)\n  if (args.auth === AuthType.Password) {\n    logger.info(\"  - Authentication is enabled\")\n    if (args.usingEnvPassword) {\n      logger.info(\"    - Using password from $PASSWORD\")\n    } else if (args.usingEnvHashedPassword) {\n      logger.info(\"    - Using password from $HASHED_PASSWORD\")\n    } else if (args[\"hashed-password\"]) {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/coder/code-server/blob/51f90a376b42e217b38937410fe2855e0c1db87e/src/node/main.ts#L119-L155","documentation":"At startup (main.ts:137) code-server validates that, when auth === AuthType.Password, at least one of `password` or `hashed-password` is set. If neither is configured the server refuses to start, because it would otherwise listen with password auth but no credential to check against.","triggerScenarios":"Running `code-server` (or with `auth: password` in config) without setting PASSWORD, HASHED_PASSWORD, `password:`, or `hashed-password:`. Common in fresh installs that default to password auth.","commonSituations":"First run after install with no config; CI/containers that set auth to password but forget the credential; purging the env and not restoring the password.","solutions":["Set PASSWORD or HASHED_PASSWORD in the environment before launch","Add `password:` (or `hashed-password:`) to ~/.config/code-server/config.yaml","If no auth is desired on a trusted network, set `auth: none` instead"],"exampleFix":"# before\ncode-server   # auth defaults to 'password', no password set\n\n# after\nexport PASSWORD=correct-horse-battery-staple\ncode-server\n# or config.yaml:\n# auth: password\n# password: correct-horse-battery-staple","handlingStrategy":"validation","validationCode":"function validatePasswordConfig(args: {\n  auth?: AuthType\n  password?: string\n  \"hashed-password\"?: string\n}): void {\n  if (args.auth === AuthType.Password && !args.password && !args[\"hashed-password\"]) {\n    throw new Error(\"auth=password requires PASSWORD or HASHED_PASSWORD to be set\")\n  }\n}","typeGuard":"function hasPasswordConfig(args: {\n  password?: string\n  \"hashed-password\"?: string\n}): boolean {\n  return Boolean(args.password || args[\"hashed-password\"])\n}","tryCatchPattern":null,"preventionTips":["Wire PASSWORD/HASHED_PASSWORD from a secrets manager before startup","Default new deployments to a generated password rather than none","Add a readiness check that fails the deploy when auth=password lacks a credential"],"tags":["auth","startup","configuration","security","password"],"backgroundTag":null,"analyzedSha":"51f90a376b42e217b38937410fe2855e0c1db87e","analyzedAt":"2026-08-12T11:27:34.273Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}