decolua/9router · error · Error
Failed to toggle DNS
Error message
Failed to toggle DNS
What it means
MitmToolCard's doDnsAction throws this when the PATCH to /api/cli-tools/antigravity-mitm fails and the response has no explicit error message. The endpoint toggles a system DNS override for the MITM tool, which typically requires elevation (sudo password); the fallback message hides whether it was auth, wrong sudo password, or an OS-level failure.
Source
Thrown at src/app/(dashboard)/dashboard/cli-tools/components/MitmToolCard.js:109
doDnsAction(action, "");
} else {
setPendingDnsAction(action);
setShowPasswordModal(true);
setModalError(null);
}
};
const doDnsAction = async (action, password) => {
setLoading(true);
setWarning(null);
try {
const res = await fetch("/api/cli-tools/antigravity-mitm", {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ tool: tool.id, action, sudoPassword: password }),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error || "Failed to toggle DNS");
if (action === "enable") {
setWarning(`Restart ${tool.name} to apply changes`);
}
setShowPasswordModal(false);
setSudoPassword("");
onDnsChange?.(data);
} catch { /* ignore */ } finally {
setLoading(false);
setPendingDnsAction(null);
}
};
const handleConfirmPassword = () => {
if (!sudoPassword.trim()) {
setModalError("Sudo password is required");
return;View on GitHub (pinned to 90b52e06ff)
Solutions
- Inspect the response body/status from the PATCH call for the server's real error text
- Re-enter the sudo password carefully (wrong passwords commonly surface as this generic error)
- Check whether the backend can modify the system resolver config (permissions, systemd-resolved conflicts) via server logs
- Retry the toggle after fixing OS-level conflicts (e.g. disable systemd-resolved DNS stub handling)
Example fix
// before
if (!res.ok) throw new Error(data.error || "Failed to toggle DNS");
// after
if (!res.ok) throw new Error(data.error || `Failed to toggle DNS (HTTP ${res.status})`); Defensive patterns
Strategy: try-catch
Validate before calling
// before toggling
if (!password) { setShowPasswordModal(true); return; } Try / catch
try {
const res = await fetch("/api/cli-tools/antigravity-mitm", { method: "PATCH", body: JSON.stringify({ tool, action, sudoPassword: password }) });
const data = await res.json().catch(() => ({}));
if (!res.ok) throw new Error(data.error || `Failed to toggle DNS (HTTP ${res.status})`);
} catch (e) {
setWarning(e.message);
} Prevention
- Confirm the sudo password before submitting; retry once on failure
- Check that the OS resolver (systemd-resolved/NetworkManager) isn't locking the config
- Surface res.status alongside data.error in the UI
- Read server logs after failed toggles
When it happens
Trigger: PATCH /api/cli-tools/antigravity-mitm with {tool, action:'enable'|'disable', sudoPassword} returns non-2xx: wrong/empty sudo password, server cannot modify resolv.conf or the OS resolver, backend helper missing, or unauthenticated session.
Common situations: User submits the password modal with an incorrect sudo password; on systems where /etc/resolv.conf is managed by systemd-resolved or NetworkManager and cannot be written; action enable/disable sent with a tool id the backend doesn't recognize.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to save mappings
- extras status failed
- Failed to start proxy
- Install failed
- Failed to fetch image: ${res.status}
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/6b662d02d33ad7d2.
Report an issue: GitHub.