Skip to content

Errors and exit codes

Scripts and coding agents can read the output of lo. This page tells the format of the JSON output, the error codes and the exit codes.

Each command accepts the global flag --json. With the flag, a command writes its result as JSON to the standard output. Progress and other messages go to the standard error.

Terminal window
lo ls --json

A command that streams, such as lo logs -f --json, writes one JSON object on each line.

When a command fails, lo writes one line to the standard error:

lo: <message>

With --json, it also writes this object to the standard output:

{
"error": {
"code": "not_found",
"message": "secret strapi/app_keys is not set; run lo secret set strapi/app_keys"
}
}
Field Type Meaning
error.code string A stable code for scripts. It is one of the four codes in the next section. The field is not present when the failure has no code, such as a failure to read a file.
error.message string The text for people. The text can change between versions, so a script must not parse it.

Some commands print a result that shows a failure, and then exit with the code 1. Examples are lo up with units that failed, lo template validate with problems, and lo doctor with failed checks. In this case, the standard output has the result only. It has one JSON document and no error object. The result tells the details: the list failed for lo up, and the list problems for lo template validate.

Code Meaning Action
invalid The request or the template is incorrect. Fixing the input fixes it. Correct the arguments, the template or the machine settings.
not_found A named workspace, template, service, resource or secret is not present. Check the name. Use lo ls --json to list the workspaces.
conflict The current state refuses the request. Read the message and change the state. Do not force the command.
unavailable Something that localspace uses is down. Tell the user. Start the thing that is down, and try again.
Code Cause
invalid A field in the template is not known. A port range in config.yaml is not valid. A workspace name has characters that are not valid. A ${env:NAME} reference to a variable that is not set.
not_found No workspace, service or resource has the name. A ${secret:<path>} secret is not set. A repo has no default ref.
conflict A workspace name is taken. lo rm finds work that is not saved in a worktree. --match finds more than one branch. lo up finds that the machine has too little free memory or disk, and you did not use --yes. The MCP server is off.
unavailable The container engine does not answer. A git remote does not answer. A plugin is down. A service is not ready after 120 seconds.

A conflict is a protection. For example, lo rm refuses to delete a worktree that has work that you did not push. Commit and push the work, then run the command again. Do not use lo rm --force unless you want to lose the work. See safety.

The dashboard API and the MCP server use the same error object. The API sets the HTTP status from the code:

Code HTTP status
invalid 400
not_found 404
conflict 409
unavailable 503

A failed MCP tool call returns the same object. See the MCP reference.

Exit code Meaning
0 The command succeeded.
1 The command ran and failed. The error object or the failed result tells the reason.
2 The command line is incorrect: an unknown command, an unknown flag or an incorrect number of arguments.

lo exec is an exception. It runs a command in a service and exits with the exit code of that command. A command that exits with 0 gives 0. A command that exits with a different number gives that number, and lo prints nothing more. Because of this, the exit code 1 or 2 from lo exec can come from your command and not from lo.

Terminal window
lo exec shop-a booking -- npm test

If lo exec cannot run the command, it fails as other commands do. For example, the workspace is not present. It prints the error and exits with 1.