Skip to main content

Troubleshooting Guide

This guide helps you diagnose and resolve common issues with the kagi CLI. It’s organized by symptom and error message for quick reference.

Quick Diagnostic Steps

When encountering any issue, follow these steps first:
  1. Check version: kagi --version
  2. Verify installation: kagi --help
  3. Test unauthenticated: kagi news --limit 1
  4. Run the auth wizard on a TTY: kagi auth
  5. Check auth status: kagi auth status
  6. Validate credentials: kagi auth check

Reading Contextual Errors

Recent kagi builds include more context in failed HTTP operations. Use these details before retrying blindly:
  • HTTP 401 or HTTP 403 usually means the API token or session token was rejected. Run kagi auth and paste a fresh token from Kagi settings.
  • ; response body: ... is a short server diagnostic. It can explain account state, insufficient credit, rate limits, or an expired session.
  • request to https://... identifies the Kagi surface that failed. This helps separate Search API issues from subscriber web-product issues.
  • batch query failed (N succeeded): query: error means only the listed batch entries failed. Retry those entries directly or lower --concurrency if the body mentions rate limits.

Installation Issues

”command not found” or “kagi is not recognized”

Symptoms:
  • Shell reports kagi: command not found
  • PowerShell reports kagi : The term '*kagi*' is not recognized
Causes:
  • Binary not in PATH
  • Shell not reloaded after installation
  • Installation didn’t complete
Solutions: 1. Find the binary:
2. Check if directory is in PATH:
3. Add to PATH manually:
4. Open new terminal window (simplest solution for PATH issues)

Permission Denied (macOS/Linux)

Symptoms:
  • bash: /path/to/*kagi*: Permission denied
Solutions:

Windows Defender / SmartScreen Blocks Installation

Symptoms:
  • “Windows protected your PC” dialog
  • “Unknown publisher” warning
Solutions:
  1. Click “More info”
  2. Click “Run anyway”
  3. Consider adding exclusion for the kagi directory
  4. Or use npm install as alternative: npm install -g kagi-cli

Installation Script Fails

Symptoms:
  • Script exits with error
  • “curl: (6) Could not resolve host”
Causes & Solutions: Network issues:
Corporate proxy:
Download and run manually:

Authentication Issues

”missing credentials” Error

Symptoms:
Diagnostic:
Solutions: 1. Set via environment variable:
2. Set via config file:
3. Common mistakes to check:
  • Variable name is KAGI_SESSION_TOKEN not KAGI_TOKEN
  • Using export not just assignment
  • No extra spaces around = in export
  • Token is complete (not truncated)

“auth check failed” Error

Symptoms:
Causes:
  1. Token is invalid or expired
  2. Token was revoked
  3. Account doesn’t have required access
  4. Rate limit exceeded
Solutions: 1. Verify token in Kagi settings:
  • Log into kagi.com
  • Check Settings → Account (for session token)
  • Check Settings → API (for API token)
  • Ensure token hasn’t been regenerated
2. Regenerate if needed:
  • Generate new token in Kagi settings
  • Update your configuration
  • Test: kagi auth check
3. Check account status:
  • Verify subscription is active (for session token)
  • Verify API credit is available (for API token)

“this command requires KAGI_API_TOKEN”

Symptoms:
Cause: Trying to use paid API commands without API token Solution:
Note: API access is separate from your Kagi subscription and requires available credit.

Environment Variable Not Being Used

Symptoms:
  • Set env var but kagi auth status shows “not configured”
  • Config file values overriding env vars (opposite of expected)
Diagnostic:
Common Causes: 1. Not exported:
2. Subshell doesn’t inherit:
3. Already set to empty:
Symptoms:
  • “Invalid token format” error
  • Authentication fails with session token
Solution: The CLI accepts both formats:
Check URL format:

Command Execution Issues

”No results found” or Empty Output

Symptoms:
  • Command runs but returns empty data array
  • JSON shows { "data": [] }
Causes & Solutions: 1. Query is too specific:
2. Rate limiting:
  • Wait a few minutes
  • Reduce request frequency
  • Check if both session token and API key are configured (fallback can help)
3. Network issues:

JSON Parse Errors

Symptoms:
Causes:
  1. Unexpected API response format
  2. Binary version incompatible with API
  3. Corrupted output
Solutions: 1. Update kagi:
2. Test raw output:
3. Clear any intermediaries:

Slow Response Times

Symptoms:
  • Commands take 10+ seconds to complete
  • Timeout errors
Causes & Solutions: 1. Network latency:
2. Fallback behavior:
  • Base search only falls back when you have opted into API-first mode with [auth.preferred_auth] = "api"
  • If the API path is slow or rejected, the session fallback adds delay
  • Leave base search on the default session-first behavior if you want to avoid that extra hop
3. Rate limiting backoff:
  • After many requests, service may slow responses
  • Add delays between requests: sleep 1

Command Hangs / No Output

Symptoms:
  • Command starts but never completes
  • No output, no error
Diagnostic:
Solutions: 1. Interrupt and retry:
2. Check network:
3. Try different command:

Platform-Specific Issues

macOS: “Cannot be opened because the developer cannot be verified”

Symptoms:
  • Gatekeeper blocks execution
  • “macOS cannot verify that this app is free from malware”
Solutions: 1. Override for this instance:
  • Go to System Preferences → Security & Privacy → General
  • Click “Allow Anyway”
  • Re-run command
2. Remove quarantine attribute:
3. Disable Gatekeeper (not recommended):

Linux: “No such file or directory” despite file existing

Symptoms:
  • ls shows file exists
  • Running it gives “No such file or directory”
Cause: Missing dynamic libraries or incompatible binary Solutions: 1. Check library dependencies:
2. Use musl build (static):
3. Install missing libraries:

Windows: PowerShell Execution Policy

Symptoms:
Solution:

Network and Connectivity Issues

Corporate Proxy / Firewall

Symptoms:
  • Commands fail with network errors
  • Works on home network but not office network
Solutions: 1. Configure proxy:
2. Use package manager install: Package managers often respect system proxy settings better than curl downloads. 3. Manual download: Download release asset via browser, then install manually.

DNS Resolution Failures

Symptoms:
  • “Could not resolve host: kagi.com”
  • Works with IP but not hostname
Solutions:

TLS / Certificate Errors

Symptoms:
  • SSL certificate verification failed
  • TLS handshake errors
Solutions: 1. Update CA certificates:
2. Check system time:

Performance Issues

High Memory Usage

Symptoms:
  • kagi process uses excessive memory
  • System slows down when using kagi
Causes & Solutions: 1. Large result sets:
2. Piping large data:

Binary Size Concerns

The kagi binary is self-contained and includes:
  • Rust runtime
  • TLS certificates
  • HTTP client libraries
This makes it larger than simple scripts but ensures it works everywhere without dependencies. Size comparison:
  • kagi binary: ~5-10 MB
  • Equivalent Python + requests: ~50+ MB installed

Debugging Techniques

Enable Verbose Output

While kagi doesn’t have a --verbose flag, you can debug:

Test Authentication Directly

Isolate Issues

Test components separately:

Collect Debug Information

When reporting issues, include:

Error Reference Quick Guide

Getting Help

If you’ve tried the solutions above and still have issues:
  1. Check GitHub Issues: github.com/Microck/kagi-cli/issues
  2. Search existing issues for your error message
  3. Create a new issue with:
    • kagi version (kagi --version)
    • Operating system and version
    • Installation method
    • Complete error message
    • Steps to reproduce
    • Debug output (with tokens redacted)

Common Gotchas

Token Confusion

  • Session Token: For subscriber features (lens, assistant)
  • API Key: For current paid API commands (search, extract)
  • Legacy API Token: For older paid API commands (fastgpt, summarize, enrich)
  • All three can exist, different commands need different ones

Bare kagi auth Fails in a Script

Symptom:
Cause: Bare kagi auth is the interactive onboarding wizard. It is meant for real terminals, not pipes or CI jobs. Fix: Use one of the explicit non-interactive subcommands:

Variable Name Typos

  • KAGI_SESSION_TOKEN
  • KAGI_SESSON_TOKEN
  • KAGI_API_KEY
  • KAGI_API_TOKEN
  • KAGI_APITOKEN

Config File Location

  • Default: ~/.config/kagi-cli/config.toml
The config file is resolved from $KAGI_CONFIG (an explicit full path), then $XDG_CONFIG_HOME/kagi-cli/config.toml, then ~/.config/kagi-cli/config.toml. A pre-existing ./.kagi.toml is no longer read; re-run kagi auth set (or kagi auth) to re-save credentials at the new location, or set KAGI_CONFIG to the old file path.

Shell Syntax


Still stuck? Check the GitHub Issues or Discussions.