Skip to main content
This guide covers common issues, debugging techniques, and solutions for OpenCode problems.

Diagnostic Steps

Before diving into specific issues, gather diagnostic information:
1

Check logs

Log files are your first stop for debugging:
ls -ltr ~/.local/share/opencode/log/
tail -f ~/.local/share/opencode/log/$(ls -t ~/.local/share/opencode/log/ | head -1)
2

Increase log verbosity

opencode --log-level DEBUG
Or set persistently:
opencode.json
{
  "logLevel": "debug"
}
3

Check version

opencode --version
Ensure you’re on the latest version:
opencode upgrade
4

Verify storage health

# Check for corruption
sqlite3 ~/.local/share/opencode/project/*/storage/*.db "PRAGMA integrity_check;"

Common Issues

OpenCode Won’t Start

Error:
bash: opencode: command not found
Cause: Binary not in PATH or installation incomplete.Solutions:
1

Verify installation

which opencode
# Should print: /usr/local/bin/opencode or ~/.local/bin/opencode
2

Reinstall if missing

curl -fsSL https://opencode.ai/install | bash
3

Add to PATH manually

# For bash
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

# For zsh
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
4

Restart terminal

Close and reopen your terminal window.
Error: OpenCode starts then exits within seconds.Debugging:
# Run with logs to stdout
opencode --print-logs

# Check for specific error messages
tail -100 ~/.local/share/opencode/log/*.log | grep -i error
Common causes:
# Find process using port 4096
lsof -i :4096

# Kill conflicting process
kill -9 <PID>

# Or use different port
opencode --port 4097
# Backup and reset config
mv ~/.config/opencode/opencode.json ~/.config/opencode/opencode.json.bak
opencode
# Fix permissions
chmod -R u+rwX ~/.local/share/opencode
chmod -R u+rwX ~/.config/opencode
Symptoms: TUI starts but shows nothing or freezes.Quick fixes:
  1. Force redraw:
    • Press Ctrl+L to redraw screen
  2. Check terminal compatibility:
    echo $TERM
    # Should be: xterm-256color, screen-256color, or similar
    
    If not, set it:
    export TERM=xterm-256color
    opencode
    
  3. Try different terminal:
    • macOS: iTerm2, Alacritty, or native Terminal.app
    • Linux: gnome-terminal, konsole, alacritty
    • Windows: Windows Terminal, not Command Prompt

Authentication Issues

Error:
ProviderAuthError: Failed to authenticate with openai
Solutions:
1

Verify API key

# Check key is set
cat ~/.local/share/opencode/auth.json | jq '.openai'

# Test key directly
curl https://api.openai.com/v1/models \
  -H "Authorization: Bearer YOUR_KEY"
2

Re-authenticate

# In OpenCode TUI
/connect

# Or via API
curl -X PUT http://localhost:4096/auth/openai \
  -H "Content-Type: application/json" \
  -d '{"apiKey": "sk-..."}'
3

Check network connectivity

# Test provider API access
curl -I https://api.openai.com
curl -I https://api.anthropic.com
If these fail, check proxy settings (see Network Configuration).
Cause: Key format issue or whitespace.Fix:
# Remove auth.json and re-add
rm ~/.local/share/opencode/auth.json
opencode
# Use /connect command
Ensure no leading/trailing whitespace:
# Wrong:
"apiKey": " sk-abc123 "

# Correct:
"apiKey": "sk-abc123"

Model Errors

Error:
ProviderModelNotFoundError: Model "gpt-4" not found
Cause: Incorrect model reference format.Solution:Models must be referenced as <providerID>/<modelID>:
{
  "model": "openai/gpt-4.1"
}
List available models:
opencode models

# Or via API
curl http://localhost:4096/provider
Common model IDs:
  • openai/gpt-4.1
  • openai/gpt-4.1-mini
  • anthropic/claude-4.5-sonnet
  • openrouter/google/gemini-2.5-flash
Error:
Model "openai/gpt-4" requires higher tier access
Causes:
  1. Model requires paid subscription
  2. Account doesn’t have access
  3. Model deprecated/renamed
Check access:
# List models you have access to
curl https://api.openai.com/v1/models \
  -H "Authorization: Bearer $OPENAI_API_KEY" | jq '.data[].id'
Fallback to available model:
opencode.json
{
  "model": "openai/gpt-4.1-mini"  // Free tier alternative
}

Provider Package Issues

Symptoms:
  • API errors mentioning unknown parameters
  • “Unexpected field” errors
  • Sudden failures after provider API updates
Cause: Cached provider packages (OpenAI SDK, Anthropic SDK, etc.) are outdated.Solution:
1

Clear provider cache

rm -rf ~/.cache/opencode
2

Restart OpenCode

opencode
OpenCode will automatically download the latest provider packages.
3

Verify fix

Check logs for successful package installation:
tail -f ~/.local/share/opencode/log/*.log | grep -i "installed"
Provider packages are cached in ~/.cache/opencode to speed up startup. Clear this if you encounter API compatibility issues.

Configuration Issues

Error:
ProviderInitError: Failed to initialize provider "openai"
Cause: Corrupted or invalid configuration.Fix:
1

Validate config syntax

# Check for JSON errors
cat ~/.config/opencode/opencode.json | jq .
# Should output formatted JSON
2

Reset config

# Backup
cp ~/.config/opencode/opencode.json{,.bak}

# Reset to minimal config
cat > ~/.config/opencode/opencode.json <<EOF
{
  "$schema": "https://opncd.ai/config.json"
}
EOF
3

Clear cached data

rm -rf ~/.local/share/opencode
This deletes all sessions and history. Backup first if needed.
4

Re-authenticate

opencode
# Run /connect command
Cause: Config cached or syntax error preventing reload.Solutions:
  1. Restart OpenCode:
    # Kill existing instance
    pkill -f opencode
    
    # Start fresh
    opencode
    
  2. Verify config location:
    # Check which config is loaded
    opencode --print-logs 2>&1 | grep -i config
    
    Config priority:
    1. .opencode/opencode.json (project-specific)
    2. ~/.config/opencode/opencode.json (user-specific)
  3. Validate syntax:
    # Must be valid JSON (no comments unless .jsonc)
    cat ~/.config/opencode/opencode.json | jq .
    

Desktop App Issues

Quick checks:
  1. Fully quit and relaunch:
    • macOS: Cmd+Q, then reopen
    • Windows: Right-click tray icon → Exit, then reopen
  2. Check for error dialog:
    • Click “Restart” button if shown
    • Copy error details for debugging
  3. macOS only - Reload webview:
    • Menu: OpenCode → Reload Webview
    • Helps if UI is blank/frozen
Symptoms: “Connection Failed” dialog on launch.Causes:
  1. Custom server URL is unreachable
  2. Port conflict preventing local server start
  3. Firewall blocking connection
Solutions:
1

Clear custom server URL

From Home screen:
  1. Click server name (with status dot)
  2. Click “Clear” in Default server section
  3. Restart app
2

Remove server config

Edit ~/.config/opencode/opencode.json, remove:
{
  "server": {
    "port": 4096,
    "hostname": "..."
  }
}
3

Check environment variables

# Unset if present
unset OPENCODE_PORT
unset OPENCODE_HOSTNAME
Symptoms: App crashes on launch after installing plugin.Fix: Disable plugins
1

Edit global config

Open:
  • macOS/Linux: ~/.config/opencode/opencode.jsonc
  • Windows: %USERPROFILE%\.config\opencode\opencode.jsonc
Set:
{
  "plugin": []  // Empty array disables all
}
2

Move plugin files

Rename plugin directories:
# Global plugins
mv ~/.config/opencode/plugins ~/.config/opencode/plugins.disabled

# Project plugins
mv .opencode/plugins .opencode/plugins.disabled
3

Restart and re-enable one by one

Once app works, re-enable plugins individually to find the culprit.
When: App behaves strangely, plugin install stuck.
# Quit app first
rm -rf ~/Library/Caches/ai.opencode.*
rm -rf ~/.cache/opencode
Requirements:
  • Notifications enabled in OS settings for OpenCode
  • App window not focused (notifications only show when backgrounded)
Enable notifications:
System Settings → Notifications → OpenCode → Allow Notifications ✓

Linux-Specific Issues

Cause: Missing clipboard utilities.Solution: Install clipboard tools
# Debian/Ubuntu
sudo apt install -y xclip

# Or alternative
sudo apt install -y xsel

# RHEL/CentOS
sudo yum install -y xclip
Verify fix:
echo "test" | xclip -selection clipboard
xclip -selection clipboard -o
# Should output: test
Symptoms: Blank window, crashes on Linux with Wayland.Try Wayland flag:
OC_ALLOW_WAYLAND=1 opencode
If worse, use X11 session:
  1. Log out
  2. At login screen, select “Ubuntu on Xorg” or “GNOME on Xorg”
  3. Log in and launch OpenCode

Windows-Specific Issues

Error: App opens to blank window (Windows only).Cause: Microsoft Edge WebView2 Runtime not installed.Solution:
1

Download WebView2 Runtime

2

Install the downloaded MSI

Run the installer and follow prompts.
3

Restart OpenCode Desktop

Should now display correctly.
Symptoms: Slow file operations, laggy terminal, high CPU.Recommended: Use WSLSee Windows WSL Guide for optimal Windows setup.WSL provides:
  • 10-20x faster file I/O
  • Better terminal support
  • Native Linux tool compatibility

Advanced Debugging

Enable Debug Logging

# Maximum verbosity
export DEBUG="*"
export LOG_LEVEL="debug"
opencode --log-level DEBUG --print-logs

Inspect Database

OpenCode uses SQLite for storage:
# List databases
find ~/.local/share/opencode -name "*.db"

# Open database
sqlite3 ~/.local/share/opencode/project/<slug>/storage/session.db

# Useful queries
SELECT * FROM session ORDER BY updated_at DESC LIMIT 5;
SELECT COUNT(*) FROM message;
PRAGMA table_info(session);

Network Debugging

# Trace HTTP requests
export DEBUG="http*"
opencode

# Test proxy connectivity
curl -x $HTTPS_PROXY https://api.openai.com/v1/models

# Check certificate issues
openssl s_client -connect api.openai.com:443 -showcerts

Profile Performance

# CPU profiling (Bun runtime)
bun --inspect opencode

# Memory usage
top -p $(pgrep -f opencode)

# Disk I/O
iotop -p $(pgrep -f opencode)

Reset Everything (Last Resort)

This deletes all OpenCode data including sessions, history, and configuration.Backup important sessions before proceeding.
# Backup (optional)
tar -czf ~/opencode-backup-$(date +%Y%m%d).tar.gz \
  ~/.local/share/opencode \
  ~/.config/opencode \
  ~/.cache/opencode

# Delete all data
rm -rf ~/.local/share/opencode
rm -rf ~/.config/opencode
rm -rf ~/.cache/opencode

# Reinstall
curl -fsSL https://opencode.ai/install | bash

# Start fresh
opencode

Getting Help

GitHub Issues

Report bugs and request features. Search existing issues first.

Discord Community

Real-time help from the community and maintainers.

Documentation

Comprehensive guides and API references.

Enterprise Support

Priority support for enterprise customers.

When Reporting Issues

Include this information:
# Copy output of:
opencode --version
uname -a  # or ver on Windows
node --version
echo $SHELL
# Include relevant log excerpts
tail -100 ~/.local/share/opencode/log/*.log
Redact sensitive info (API keys, file paths).
# Share config (redact secrets)
cat ~/.config/opencode/opencode.json
  1. Step-by-step instructions to reproduce
  2. Expected behavior
  3. Actual behavior
  4. Screenshots/screencasts if applicable

Preventive Measures

Keep Updated

opencode upgrade
Run monthly to get latest fixes.

Backup Sessions

# Periodic backups
tar -czf ~/opencode-backup.tar.gz ~/.local/share/opencode/project

Monitor Logs

Check logs after updates:
tail -f ~/.local/share/opencode/log/*.log

Test Config Changes

Test config in isolated session:
opencode --config /tmp/test-config.json

Next Steps

Server Configuration

Advanced server setup and debugging.

Network Setup

Resolve proxy and certificate issues.

Windows WSL

Fix Windows-specific performance issues.