Skip to main content
Common issues and solutions for the LeadMagic CLI.

Quick Diagnostics

Run the built-in health check:
Auto-repair fixable issues:
Verbose diagnostics:
lm doctor checks your config file, database, authentication status, and system requirements.

Debug Logging

Enable detailed logging for any command:
Or set the environment variable:
Debug output includes API requests, tool calls, database queries, and internal state.

Authentication Issues

Error: Not logged in, Authentication required, or Session expiredSolutions:
  1. Sign in again:
  1. Verify the session:
  1. Run diagnostics:
Error: Session expired or Token refresh failedSolution: Sign in again:
OAuth tokens expire periodically. The CLI attempts automatic refresh, but if that fails, a fresh login is needed.
Possible causes:
  • No default browser configured
  • Running in a headless environment (SSH, Docker)
Solution: Copy the URL printed in the terminal and open it manually in any browser. After authenticating, the CLI picks up the token automatically.

Database Issues

Error: Database is locked or Could not set lockCause: Another lm process is holding the database lock.Solutions:
  1. Unlock the database:
Or without confirmation:
  1. If that doesn’t work, check for orphaned processes:
Error: WAL corruption, schema mismatch, or database errors.Solutions:
  1. Repair (preserves data when possible):
  1. Reset (destructive — drops all tables):
Exported files in .leadmagic/export/ are not affected by reset.
Solution: Compact the database to reclaim space:
This runs VACUUM, updates statistics, and flushes the write-ahead log.

File and Data Issues

The CLI enforces row limits for safety:Solutions:
  • Split large files before loading
  • Filter rows using SQL after loading a subset
  • Use the REST API directly for large-scale batch processing
Common causes:
  • Non-standard delimiters (the CLI auto-detects commas, tabs, semicolons, and pipes)
  • Encoding issues (the CLI handles UTF-8 and BOM)
  • Malformed quotes or escaped characters
Solutions:
  1. Try analyzing the file first:
  1. Check the file encoding — the CLI works best with UTF-8.
  2. If the file uses an unusual delimiter, the CLI auto-detects it in most cases. If detection fails, pre-process the file to use standard CSV formatting.
Cause: Column names don’t match expected patterns (e.g., email, first_name, company).Solutions:
  • Specify columns explicitly with --email-column, --first-name-column, etc. when using lm enrich
  • In chat, tell the AI which column contains what: “The email addresses are in column C”
  • Run lm analyze to see what the CLI detected

Connection Issues

Possible causes:
  • No internet connection
  • LeadMagic API is temporarily down
  • Your OAuth session is invalid or expired
Solutions:
  1. Check your internet connection
  2. Verify your account session:
  1. Check the API status at leadmagic.io/status
Cause: The AI Gateway (ai.leadmagic.io) may be unreachable.Solutions:
  1. Check you’re logged in:
  1. Re-authenticate:
  1. Try with debug logging to see the actual error:

Common Error Messages

Reset Everything

If all else fails, you can reset your entire CLI installation:
This preserves your exported files in .leadmagic/export/ but removes all loaded data and configuration.

Still Need Help?

Help Center

Contact support for account or billing issues.

API Status

Check if the LeadMagic API is operational.