Dokploy/dokploy · warning · Error
File not found: ${configPath}
Error message
File not found: ${configPath} What it means
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.
Source
Thrown at packages/server/src/utils/traefik/middleware.ts:82
for (const redirect of redirects) {
const middlewareName = `redirect-${appName}-${redirect.uniqueConfigKey}`;
delete config.http.middlewares[middlewareName];
}
}
if (serverId) {
await writeTraefikConfigRemote(config, "middlewares", serverId);
} else {
writeMiddleware(config);
}
};
export const loadMiddlewares = <T>() => {
const { DYNAMIC_TRAEFIK_PATH } = paths();
const configPath = join(DYNAMIC_TRAEFIK_PATH, "middlewares.yml");
if (!existsSync(configPath)) {
throw new Error(`File not found: ${configPath}`);
}
const yamlStr = readFileSync(configPath, "utf8");
const config = parse(yamlStr) as T;
return config;
};
export const loadRemoteMiddlewares = async (serverId: string) => {
const { DYNAMIC_TRAEFIK_PATH } = paths(true);
const configPath = join(DYNAMIC_TRAEFIK_PATH, "middlewares.yml");
try {
const { stdout, stderr } = await execAsyncRemote(
serverId,
`cat ${configPath}`,
);
if (stderr) {
console.error(`Error: ${stderr}`);View on GitHub (pinned to 546686ea35)
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
Example fix
// before
if (!existsSync(configPath)) {
throw new Error(`File not found: ${configPath}`);
}
// after
if (!existsSync(configPath)) {
return { http: { middlewares: {} } } as T;
} Defensive patterns
Strategy: fallback
Validate before calling
if (!existsSync(configPath)) {
writeFileSync(configPath, 'http:\n middlewares: {}\n');
} Try / catch
let config;
try {
config = loadMiddlewares();
} catch {
config = { http: { middlewares: {} } } as FileConfig; // treat as empty
} Prevention
- Initialize Traefik dynamic config during setup
- Back up the dynamic config directory
When it happens
Trigger: 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.
Common situations: Fresh Dokploy setup where Traefik config hasn't been initialized; manually cleaned docker volume holding traefik config.
Related errors
AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27).
Data as JSON: /api/errors/7b157ce3792c9e6b.
Report an issue: GitHub.