{"record":{"id":"7b157ce3792c9e6b","repo":"Dokploy/dokploy","slug":"file-not-found-configpath","errorCode":null,"errorMessage":"File not found: ${configPath}","messagePattern":"File not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/server/src/utils/traefik/middleware.ts","lineNumber":82,"sourceCode":"\n\t\tfor (const redirect of redirects) {\n\t\t\tconst middlewareName = `redirect-${appName}-${redirect.uniqueConfigKey}`;\n\t\t\tdelete config.http.middlewares[middlewareName];\n\t\t}\n\t}\n\n\tif (serverId) {\n\t\tawait writeTraefikConfigRemote(config, \"middlewares\", serverId);\n\t} else {\n\t\twriteMiddleware(config);\n\t}\n};\n\nexport const loadMiddlewares = <T>() => {\n\tconst { DYNAMIC_TRAEFIK_PATH } = paths();\n\tconst configPath = join(DYNAMIC_TRAEFIK_PATH, \"middlewares.yml\");\n\tif (!existsSync(configPath)) {\n\t\tthrow new Error(`File not found: ${configPath}`);\n\t}\n\tconst yamlStr = readFileSync(configPath, \"utf8\");\n\tconst config = parse(yamlStr) as T;\n\treturn config;\n};\n\nexport const loadRemoteMiddlewares = async (serverId: string) => {\n\tconst { DYNAMIC_TRAEFIK_PATH } = paths(true);\n\tconst configPath = join(DYNAMIC_TRAEFIK_PATH, \"middlewares.yml\");\n\n\ttry {\n\t\tconst { stdout, stderr } = await execAsyncRemote(\n\t\t\tserverId,\n\t\t\t`cat ${configPath}`,\n\t\t);\n\n\t\tif (stderr) {\n\t\t\tconsole.error(`Error: ${stderr}`);","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/utils/traefik/middleware.ts#L64-L100","documentation":"loadMiddlewares reads the local Traefik dynamic config file middlewares.yml under DYNAMIC_TRAEFIK_PATH; if it doesn't exist yet, it throws. This typically happens on a fresh install before any middleware has been written.","triggerScenarios":"First call to createPathMiddlewares/removePathMiddlewares/deleteAllMiddlewares before middlewares.yml was ever created; the dynamic config directory was wiped or moved; wrong DYNAMIC_TRAEFIK_PATH env.","commonSituations":"Fresh Dokploy setup where Traefik config hasn't been initialized; manually cleaned docker volume holding traefik config.","solutions":["Initialize Traefik config (restart Dokploy / trigger config setup) so middlewares.yml is created","If the file is legitimately optional, create it with empty http: middlewares: {} structure","Verify DYNAMIC_TRAEFIK_PATH points at the mounted Traefik dynamic config dir","Restore the file from backup if it was accidentally deleted"],"exampleFix":"// before\nif (!existsSync(configPath)) {\n  throw new Error(`File not found: ${configPath}`);\n}\n\n// after\nif (!existsSync(configPath)) {\n  return { http: { middlewares: {} } } as T;\n}","handlingStrategy":"fallback","validationCode":"if (!existsSync(configPath)) {\n  writeFileSync(configPath, 'http:\\n  middlewares: {}\\n');\n}","typeGuard":null,"tryCatchPattern":"let config;\ntry {\n  config = loadMiddlewares();\n} catch {\n  config = { http: { middlewares: {} } } as FileConfig; // treat as empty\n}","preventionTips":["Initialize Traefik dynamic config during setup","Back up the dynamic config directory"],"tags":["traefik","middleware","file-not-found","config"],"backgroundTag":"config-file-missing","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}