louislam/dockge · error · Error
Dockge has been initialized. If you want to run setup again,
Error message
Dockge has been initialized. If you want to run setup again, please delete the database.
What it means
The 'setup' socket handler is a one-time initialization path. Before creating the admin user it counts rows in the 'user' table via knex; if any user already exists the instance is considered initialized and this Error is thrown to prevent re-running setup. This protects existing accounts from being overwritten by a second setup call.
Source
Thrown at backend/socket-handlers/main-socket-handler.ts:39
import fs, { promises as fsAsync } from "fs";
import path from "path";
export class MainSocketHandler extends SocketHandler {
create(socket : DockgeSocket, server : DockgeServer) {
// ***************************
// Public Socket API
// ***************************
// Setup
socket.on("setup", async (username, password, callback) => {
try {
if (passwordStrength(password).value === "Too weak") {
throw new Error("Password is too weak. It should contain alphabetic and numeric characters. It must be at least 6 characters in length.");
}
if ((await R.knex("user").count("id as count").first()).count !== 0) {
throw new Error("Dockge has been initialized. If you want to run setup again, please delete the database.");
}
const user = R.dispense("user");
user.username = username;
user.password = generatePasswordHash(password);
await R.store(user);
server.needSetup = false;
callback({
ok: true,
msg: "successAdded",
msgi18n: true,
});
} catch (e) {
if (e instanceof Error) {
callback({View on GitHub (pinned to f809ae192b)
Solutions
- Do not call 'setup' — the instance already has an admin account; log in instead.
- To genuinely re-initialize, stop Dockge and delete the database file (data/stacks.db by default), then restart and run setup.
- Reset the password via the changePassword flow after authenticating with the existing account.
Example fix
// before (against initialized instance)
socket.emit('setup', 'admin', 'newpass1', cb);
// after
if (server.needSetup) {
socket.emit('setup', 'admin', 'newpass1', cb);
} else {
socket.emit('login', 'admin', 'existingpass', cb);
} Defensive patterns
Strategy: validation
Validate before calling
// Only run setup when the server reports it needs setup
if (serverState.needSetup) {
socket.emit('setup', username, password, cb);
} else {
socket.emit('login', username, password, cb);
} Type guard
function isFreshInstance(s) { return s.needSetup === true; } Try / catch
socket.emit('setup', username, password, (res) => {
if (!res.ok && /initialized/.test(res.msg)) {
redirectToLogin();
}
}); Prevention
- Gate setup UI/flows on the server's needSetup flag
- Check whether an admin can log in before attempting setup
- Never delete the DB file unless a full re-init is intended
When it happens
Trigger: Emitting the 'setup' socket event when the 'user' table already contains at least one row (server.needSetup is false).
Common situations: Re-running a provisioning script against an already-initialized Dockge instance; pointing a new frontend at an existing database file; attempting to reset a forgotten admin password by replaying setup instead of deleting the DB.
Related errors
- Password is too weak. It should contain alphabetic and numer
- Agent not found
- Invalid db-config.json, it must be an object
- Invalid db-config.json, type must be a string
- Unknown Database type:
AI-assisted analysis of louislam/dockge@f809ae192b (2026-08-31).
Data as JSON: /api/errors/d553df03c68236c5.
Report an issue: GitHub.