When something goes wrong, moodle-cli prints an error name (like auth) and a hint telling you what to do. This page lists what you might see and how to fix it. Scripting this? See Moodle CLI for scripts and agents for the full error and exit-code reference.

Error codes

submit, uninstall, auth login, auth keepalive install/auth keepalive uninstall, and the mcp deployment commands all mutate state and go through the same plan-confirm flow; see Mutations for the full list.

ambiguous — a reference matched more than one thing

A UNIT, section or item phrase that matches more than one record fails and lists every match, instead of guessing. See How ambiguity resolves for the interactive picker moodle-cli shows at a terminal. Fix: use one of the listed candidates, or narrow the phrase until only one thing matches. Symptom: moodle doctor’s browser check reports fail, or an auth error’s hint mentions Full Disk Access. Cause: Full Disk Access is granted to your terminal application, never to the CLI process itself, and a sandboxed terminal (an IDE’s integrated terminal, an agent runner) usually can’t be granted it at all. See macOS Full Disk Access and cookie stores for which cookie stores this affects and why. Fix: grant Full Disk Access to the terminal app named in the hint, then fully restart that app — not just the tab:
Or skip the store entirely:

Expired session

Symptom: a command that worked yesterday now fails with auth, or moodle auth status reports session_alive: false. Fix: re-authenticate:
If you rely on a deployed MCP (Model Context Protocol) server rather than the local CLI, its session expires independently of your terminal’s saved one; moodle mcp login sends it a fresh session. See Connect an agent for that flow.

Keepalive not running

Symptom: sessions keep expiring even though you installed keepalive. Check:
A job check failing in moodle doctor means the background job can no longer read browser cookies (for example, after switching Node versions) or its runtime no longer exists. Reinstall it:
On Linux there’s no job to check — keepalive only runs if you scheduled the cron line yourself; see Keepalive.

Cloudflare deployment problems

Deployment and remote-session issues for the managed MCP server (Cloudflare sign-in, Worker deploy failures, OAuth pairing) are specific to that surface and covered in Connect an agent and MCP troubleshooting. moodle mcp status --verbose and moodle doctor’s mcp check are the starting points; moodle mcp deploy --repair is the general-purpose fix for a deployment stuck in a bad state.

What moodle doctor checks mean

moodle doctor runs the checks documented in Sign in: sqlite, config, session, browser, one job per background job you have running, and mcp. Only sqlite, config and browser can report fail; session, job and mcp only ever report pass or warn.

Check your site with moodle coverage

Moodle sites differ: some turn off web services, and themes, languages and course formats change the pages moodle-cli reads. moodle-cli asks your site for its own wording of the labels it looks for, so a site in another language, or one that renamed a label, is read the same way. moodle coverage signs in with your session and runs each read-only command once against your own units, printing one line per command as it finishes. Nothing is created and submitting is never tried. Moodle does log the pages it opens as views, as it does when you browse them, and can mark forum posts read. A command passes only when its answer agrees with what the site states elsewhere: an activity’s name and files against the unit’s contents, an assignment’s due date against the calendar, a forum search against a discussion the forum is known to hold. Each passing line says what it was checked against. The other outcomes are: Only activities you can open are sampled, a network error is retried once, and a check that hangs times out. The command exits with code 3 when a command fails, contradicts the site, or reads a page it does not understand. The first line names your moodle-cli version and whether it is the latest. A failure from an old release may already be fixed, so run moodle update before reporting one. The JSON report adds the moodle-cli version and runtime, the Moodle release and theme, and the services the site turns off. It holds counts, ids and error messages, not your name or the titles of your units, so you can attach it to an issue when your site misbehaves.