* docs: document model/auth settings, /model --vision, and --safe-mode Refresh user docs to match the current codebase: - commands.md: add the /model --vision override (vision-bridge model) - settings.md: add model.baseUrl, model.sessionTokenLimit, visionModel, and voiceModel; document the deprecated security.auth.apiKey and security.auth.baseUrl keys with a pointer to modelProviders - troubleshooting.md: document the --safe-mode flag for isolating customization issues * docs: address review feedback on sessionTokenLimit, safe-mode, deprecation notes - model.sessionTokenLimit: correct default to -1 (runtime fallback in core/config.ts) and clarify breach behavior (current send dropped, not session abort) per client.ts SessionTokenLimitExceeded handling. - --safe-mode: expand the disabled-customizations list to also cover permission rules, approval mode overrides, memory features, and sandbox settings, matching cli/config.ts. - security.auth.apiKey/baseUrl: align deprecation wording with the existing tools.* entries (**Deprecated.**) and drop the unsubstantiated '(slated for removal)' qualifier. * docs: note QWEN_CODE_SAFE_MODE env var as a safe-mode alternative Document the QWEN_CODE_SAFE_MODE=true environment variable as an alternative activation path for safe mode, for cases where the CLI cannot accept flags (verified against isSafeModeEnv in packages/core/src/utils/safe-mode.ts). * docs: clarify model.baseUrl, sessionTokenLimit=0, and safe-mode subagents - model.baseUrl: describe it as a picker-managed disambiguator, not a hand-editable override (stale values can misroute to a same-id provider). - model.sessionTokenLimit: note that 0 is treated as unlimited (same as -1), unlike model.maxToolCalls where 0 disallows all calls. - --safe-mode: include custom subagents in the list of disabled customizations (only built-in subagents load in safe mode). * docs: clarify sessionTokenLimit semantics and add --safe-mode to headless flags - settings.md: reword model.sessionTokenLimit to reflect that the gate compares the last recorded prompt token count before the next send (not a per-send preflight cap), and that the next send is dropped. - headless.md: add a --safe-mode row to the CLI flags table so the diagnostic flag is discoverable there, cross-referencing Troubleshooting. * docs: align safe-mode sandbox wording to 'sandbox settings' Safe mode passes an empty Settings object to loadSandboxConfig (packages/cli/src/config/config.ts:1793), so it strips settings-sourced sandbox config while the --sandbox flag and QWEN_SANDBOX env still apply. Match headless.md to troubleshooting.md's accurate 'sandbox settings'. * docs: correct safe-mode approval-mode wording and align both lists Safe mode only strips settings-sourced approval mode; the --yolo and --approval-mode CLI flags are evaluated before the safeMode guard (packages/cli/src/config/config.ts:1521-1528) and still take effect. Reword to 'settings-sourced approval mode overrides' and note the CLI flags in troubleshooting.md and headless.md, and make the enumerated safe-mode disable list identical (same items and order) across both. --------- Co-authored-by: Claude <noreply@anthropic.com>
12 KiB
Troubleshooting
This guide provides solutions to common issues and debugging tips, including topics on:
- Authentication or login errors
- Frequently asked questions (FAQs)
- Debugging tips
- Existing GitHub Issues similar to yours or creating new Issues
Authentication or login errors
-
Error:
Qwen OAuth free tier was discontinued on 2026-04-15- Cause: Qwen OAuth is no longer available as of April 15, 2026.
- Solution: Switch to a different authentication method. Run
qwen→/authand choose one of:
-
Error:
UNABLE_TO_GET_ISSUER_CERT_LOCALLY,UNABLE_TO_VERIFY_LEAF_SIGNATURE, orunable to get local issuer certificate- Cause: You may be on a corporate network with a firewall that intercepts and inspects SSL/TLS traffic. This often requires a custom root CA certificate to be trusted by Node.js.
- Solution: Set the
NODE_EXTRA_CA_CERTSenvironment variable to the absolute path of your corporate root CA certificate file.- Example:
export NODE_EXTRA_CA_CERTS=/path/to/your/corporate-ca.crt
- Example:
-
Error:
Connection error. (cause: fetch failed)against a self-signed endpoint- Cause: You are pointing Qwen Code at a self-hosted server (for example a local model behind
https://) whose TLS certificate is self-signed, so Node.js rejects it. - Solution: Prefer trusting the certificate via
NODE_EXTRA_CA_CERTS(above). If that is not practical in a trusted lab/private network, skip verification with the--insecureflag (orQWEN_TLS_INSECURE=1):- Example:
qwen --insecure --openaiBaseUrl https://192.168.1.10:8080 ... - Warning: Disabling verification removes protection against man-in-the-middle attacks. Only use it for endpoints you fully trust.
- Example:
- Cause: You are pointing Qwen Code at a self-hosted server (for example a local model behind
-
Error:
Device authorization flow failed: fetch failed- Cause: Node.js could not reach Qwen OAuth endpoints (often a proxy or SSL/TLS trust issue). When available, Qwen Code will also print the underlying error cause (for example:
UNABLE_TO_VERIFY_LEAF_SIGNATURE). Note: this error is specific to the legacy Qwen OAuth flow. - Solution:
- If you are still using Qwen OAuth, switch to API Key or Coding Plan via
/auth. - If you are behind a proxy, set it via
qwen --proxy <url>(or theproxysetting insettings.json). - If your network uses a corporate TLS inspection CA, set
NODE_EXTRA_CA_CERTSas described above.
- If you are still using Qwen OAuth, switch to API Key or Coding Plan via
- Cause: Node.js could not reach Qwen OAuth endpoints (often a proxy or SSL/TLS trust issue). When available, Qwen Code will also print the underlying error cause (for example:
-
Issue: Unable to display UI after authentication failure
- Cause: If authentication fails after selecting an authentication type, the
security.auth.selectedTypesetting may be persisted insettings.json. On restart, the CLI may get stuck trying to authenticate with the failed auth type and fail to display the UI. - Solution: Clear the
security.auth.selectedTypeconfiguration item in yoursettings.jsonfile:- Open
~/.qwen/settings.json(or./.qwen/settings.jsonfor project-specific settings) - Remove the
security.auth.selectedTypefield - Restart the CLI to allow it to prompt for authentication again
- Open
- Cause: If authentication fails after selecting an authentication type, the
Frequently asked questions (FAQs)
-
Q: How do I update Qwen Code to the latest version?
- A: If you installed Qwen Code with the standalone installer, rerun the standalone install command. If you installed it globally via
npm, update it using the commandnpm install -g @qwen-code/qwen-code@latest. If you compiled it from source, pull the latest changes from the repository, and then rebuild using the commandnpm run build.
- A: If you installed Qwen Code with the standalone installer, rerun the standalone install command. If you installed it globally via
-
Q: Where are the Qwen Code configuration or settings files stored?
-
A: The Qwen Code configuration is stored in two
settings.jsonfiles:- In your home directory:
~/.qwen/settings.json. - In your project's root directory:
./.qwen/settings.json.
Refer to Qwen Code Configuration for more details.
- In your home directory:
-
-
Q: Why don't I see cached token counts in my stats output?
- A: Cached token information is only displayed when cached tokens are being used. This feature is available for API key users (e.g., Alibaba Cloud Model Studio API key or Google Cloud Vertex AI). You can still view your total token usage using the
/statscommand.
- A: Cached token information is only displayed when cached tokens are being used. This feature is available for API key users (e.g., Alibaba Cloud Model Studio API key or Google Cloud Vertex AI). You can still view your total token usage using the
-
Q: A customization (extension, hook, skill, MCP server, or subagent) seems to be breaking Qwen Code. How do I isolate it?
- A: Start Qwen Code with the
--safe-modeflag to disable all customizations — context files, hooks, extensions, skills, MCP servers, custom subagents (only built-in subagents load), permission rules, settings-sourced approval mode overrides, memory features, and sandbox settings — for the session. Note: the CLI flags--yoloand--approval-modestill take effect in safe mode. If the problem disappears in safe mode, re-enable your customizations one at a time to find the culprit.- Example:
qwen --safe-mode - Alternative: set the environment variable
QWEN_CODE_SAFE_MODE=trueif the CLI cannot accept flags.
- Example:
- A: Start Qwen Code with the
Common error messages and solutions
-
Error:
EADDRINUSE(Address already in use) when starting an MCP server.- Cause: Another process is already using the port that the MCP server is trying to bind to.
- Solution: Either stop the other process that is using the port or configure the MCP server to use a different port.
-
Error: Command not found (when attempting to run Qwen Code with
qwen).- Cause: The CLI is not correctly installed or it is not in your system's
PATH. - Solution:
The update depends on how you installed Qwen Code:
- If you installed
qwenwith the standalone installer, rerun the standalone install command and then open a new terminal. - If you installed
qwenglobally, check that yournpmglobal binary directory is in yourPATH. You can update using the commandnpm install -g @qwen-code/qwen-code@latest. - If you are running
qwenfrom source, ensure you are using the correct command to invoke it (e.g.node packages/cli/dist/index.js ...). To update, pull the latest changes from the repository, and then rebuild using the commandnpm run build.
- If you installed
- Cause: The CLI is not correctly installed or it is not in your system's
-
Error:
MODULE_NOT_FOUNDor import errors.- Cause: Dependencies are not installed correctly, or the project hasn't been built.
- Solution:
- Run
npm installto ensure all dependencies are present. - Run
npm run buildto compile the project. - Verify that the build completed successfully with
npm run start.
- Run
-
Error: "Operation not permitted", "Permission denied", or similar.
- Cause: When sandboxing is enabled, Qwen Code may attempt operations that are restricted by your sandbox configuration, such as writing outside the project directory or system temp directory.
- Solution: Refer to the Configuration: Sandboxing documentation for more information, including how to customize your sandbox configuration.
-
Qwen Code is not running in interactive mode in "CI" environments
- Issue: Qwen Code does not enter interactive mode (no prompt appears) if an environment variable starting with
CI_(e.g.CI_TOKEN) is set. This is because theis-in-cipackage, used by the underlying UI framework, detects these variables and assumes a non-interactive CI environment. - Cause: The
is-in-cipackage checks for the presence ofCI,CONTINUOUS_INTEGRATION, or any environment variable with aCI_prefix. When any of these are found, it signals that the environment is non-interactive, which prevents the CLI from starting in its interactive mode. - Solution: If the
CI_prefixed variable is not needed for the CLI to function, you can temporarily unset it for the command. e.g.env -u CI_TOKEN qwen
- Issue: Qwen Code does not enter interactive mode (no prompt appears) if an environment variable starting with
-
DEBUG mode not working from project .env file
- Issue: Setting
DEBUG=truein a project's.envfile doesn't enable debug mode for the CLI. - Cause: The
DEBUGandDEBUG_MODEvariables are automatically excluded from project.envfiles to prevent interference with the CLI behavior. - Solution: Use a
.qwen/.envfile instead, or configure theadvanced.excludedEnvVarssetting in yoursettings.jsonto exclude fewer variables.
- Issue: Setting
-
Trackpad scrolling in tmux changes prompt history instead of scrolling the conversation
- Issue: In a tmux session, trackpad or wheel scrolling may cycle through previous prompts, similar to pressing
Up ArroworDown Arrow. - Cause: tmux can translate wheel gestures into plain arrow-key sequences. Those sequences are indistinguishable from real arrow-key presses by the time qwen-code receives them.
- Solution: Enable
ui.useTerminalBuffer; then useShift+Up/Shift+Down, or the mouse wheel when tmux forwards wheel events to the app. If you prefer host scrollback, adjust your tmux mouse bindings for wheel events.
- Issue: In a tmux session, trackpad or wheel scrolling may cycle through previous prompts, similar to pressing
IDE Companion not connecting
- Ensure VS Code has a single workspace folder open.
- Restart the integrated terminal after installing the extension so it inherits:
QWEN_CODE_IDE_WORKSPACE_PATHQWEN_CODE_IDE_SERVER_PORT
- If running in a container, verify
host.docker.internalresolves. Otherwise, map the host appropriately. - Reinstall the companion with
/ide installand use “Qwen Code: Run” in the Command Palette to verify it launches.
Exit Codes
The Qwen Code uses specific exit codes to indicate the reason for termination. This is especially useful for scripting and automation.
| Exit Code | Error Type | Description |
|---|---|---|
| 41 | FatalAuthenticationError |
An error occurred during the authentication process. |
| 42 | FatalInputError |
Invalid or missing input was provided to the CLI. (non-interactive mode only) |
| 44 | FatalSandboxError |
An error occurred with the sandboxing environment (e.g. Docker, Podman, or Seatbelt). |
| 52 | FatalConfigError |
A configuration file (settings.json) is invalid or contains errors. |
| 53 | FatalTurnLimitedError |
The maximum number of conversational turns for the session was reached. (non-interactive mode only) |
Debugging Tips
-
CLI debugging:
- Use the
--verboseflag (if available) with CLI commands for more detailed output. - Check the CLI logs, often found in a user-specific configuration or cache directory.
- Use the
-
Core debugging:
- Check the server console output for error messages or stack traces.
- Increase log verbosity if configurable.
- Use Node.js debugging tools (e.g.
node --inspect) if you need to step through server-side code.
-
Tool issues:
- If a specific tool is failing, try to isolate the issue by running the simplest possible version of the command or operation the tool performs.
- For
run_shell_command, check that the command works directly in your shell first. - For file system tools, verify that paths are correct and check the permissions.
-
Pre-flight checks:
- Always run
npm run preflightbefore committing code. This can catch many common issues related to formatting, linting, and type errors.
- Always run
Existing GitHub Issues similar to yours or creating new Issues
If you encounter an issue that was not covered here in this Troubleshooting guide, consider searching the Qwen Code Issue tracker on GitHub. If you can't find an issue similar to yours, consider creating a new GitHub Issue with a detailed description. Pull requests are also welcome!