{"record":{"id":"b79b076a5823b4fa","repo":"NginxProxyManager/nginx-proxy-manager","slug":"database-config-does-not-exist-please-read-the-in","errorCode":null,"errorMessage":"Database config does not exist! Please read the instructions: https://nginxproxymanager.com/setup/","messagePattern":"Database config does not exist! Please read the instructions: https://nginxproxymanager\\.com/setup/","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"backend/db.js","lineNumber":8,"sourceCode":"import knex from \"knex\";\nimport { configGet, configHas } from \"./lib/config.js\";\n\nlet instance = null;\n\nconst generateDbConfig = () => {\n\tif (!configHas(\"database\")) {\n\t\tthrow new Error(\n\t\t\t\"Database config does not exist! Please read the instructions: https://nginxproxymanager.com/setup/\",\n\t\t);\n\t}\n\n\tconst cfg = configGet(\"database\");\n\n\tif (cfg.engine === \"knex-native\") {\n\t\treturn cfg.knex;\n\t}\n\n\treturn {\n\t\tclient: cfg.engine,\n\t\tconnection: {\n\t\t\thost: cfg.host,\n\t\t\tuser: cfg.user,\n\t\t\tpassword: cfg.password,\n\t\t\tdatabase: cfg.name,\n\t\t\tport: cfg.port,","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/NginxProxyManager/nginx-proxy-manager/blob/934a3fafe5ae82d752f0a18c0f1d0eb050296730/backend/db.js#L1-L26","documentation":"Nginx Proxy Manager reads its configuration from config.json (or corresponding environment variables) at startup. generateDbConfig throws this error when the 'database' key is missing entirely, meaning the app has no way to connect to any database backend (SQLite, MySQL, or Postgres). It is thrown lazily the first time the database singleton is requested via getInstance, so a totally absent config fails fast rather than producing confusing downstream connection errors.","triggerScenarios":"Starting the backend without a config.json file in the backend directory, or with a config.json that lacks the top-level \"database\" object. Also occurs when environment-based configuration is expected but the relevant env vars/config file were never created, e.g. running `node index.js` directly after a fresh clone without following setup docs.","commonSituations":"Fresh installs where the user skipped the setup instructions, Docker volumes that mount over /etc/nginx-proxy-manager and hide the default config.json, config.json with a typo in the key name (e.g. \"databases\"), or running from the wrong working directory so the config loader cannot find the file.","solutions":["Create or restore backend/config.json with a \"database\" block; simplest is the default SQLite config: {\"database\":{\"engine\":\"sqlite\",\"filename\":\"/data/database.sqlite\"}}","If using Docker, ensure the config file is correctly mounted/copied into the image and that /data exists and is writable","Verify the config key is exactly \"database\" (singular) and the JSON is valid (no trailing commas, correct quotes)","In dev environments, copy the provided example config (config.example.json or the one from the setup docs) and edit it rather than writing from scratch"],"exampleFix":"// before: config.json is missing or has no database key\n{}\n\n// after\n{\n  \"database\": {\n    \"engine\": \"sqlite\",\n    \"filename\": \"/data/database.sqlite\"\n  }\n}","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\n\nconst hasDbConfig = (path = 'config.json') => {\n  if (!fs.existsSync(path)) return false;\n  try {\n    return Object.prototype.hasOwnProperty.call(JSON.parse(fs.readFileSync(path, 'utf8')), 'database');\n  } catch {\n    return false;\n  }\n};\n\nif (!hasDbConfig()) {\n  console.error('Missing config.json database block — see https://nginxproxymanager.com/setup/');\n  process.exit(1);\n}","typeGuard":"const hasDatabaseConfig = (cfg: unknown): cfg is { database: Record<string, unknown> } =>\n  typeof cfg === 'object' && cfg !== null && 'database' in cfg;","tryCatchPattern":"try {\n  const db = getInstance();\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Database config does not exist')) {\n    // surface setup instructions, fail startup cleanly\n  }\n  throw e;\n}","preventionTips":["Commit a validated config.example.json and CI-check that config.json parses and has a database key before boot","In Docker, healthcheck startup logs for this message and fail the container early","Never hand-edit JSON without re-parsing it (json.loads / JSON.parse) as a smoke test"],"tags":["nginx-proxy-manager","configuration","database","startup","config-json"],"backgroundTag":"missing-config-value","analyzedSha":"934a3fafe5ae82d752f0a18c0f1d0eb050296730","analyzedAt":"2026-08-27T14:34:22.258Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}