Troubleshooting

Common daemon issues and their solutions. If you encounter a problem not listed here, check the daemon logs with opta daemon logs for detailed error messages.

Daemon Exits Immediately

If opta daemon start exits without error output, the most common cause is a port conflict.

Port in Use

The daemon tries to bind to port 9999. If that port is taken, it scans ports 10000 through 10020. If all ports are occupied, the daemon fails to start.

Check what is using port 9999
lsof -i :9999
COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
node    12345  matt   22u  IPv4  0x...  0t0  TCP localhost:9999 (LISTEN)

If another process owns the port, either stop that process or configure the daemon to use a different port range:

Kill the conflicting process and restart
kill 12345 && opta daemon start
Multiple daemon instances
Never run two daemon instances. If you see a daemon already listening, use opta daemon status to check whether it is a legitimate Opta daemon before killing it.

WebSocket Drops

WebSocket connections can drop for several reasons. The most common is the LMX server becoming unreachable during inference.

LMX Unreachable

If the daemon cannot reach the LMX server at 192.168.188.11:1234, it will emit a turn.error event with code LMX_UNREACHABLE. The WebSocket connection itself stays open, but inference fails.

1

Check LMX is running

curl http://192.168.188.11:1234/healthz
{"status":"ok"}
2

Check network connectivity

Verify LAN connection to Mac Studio
ping -c 3 192.168.188.11
3

Check LMX has a model loaded

curl http://192.168.188.11:1234/readyz
{"ready":true,"model":"qwen3-30b-a3b"}
Never use Tailscale
Always connect to the Mac Studio over LAN (192.168.188.11). Tailscale adds latency and is not supported for LMX connections.

Permission Requests Hang

If a turn appears stuck, it may be waiting for a permission approval that was never resolved. This happens when a client disconnects while a permission.request event is pending.

To unblock the session:

1

Check for pending permissions

Connect to the WebSocket or poll events to find any unresolved permission.request events.

2

Cancel the stuck turn

Replace SESSION_ID and TOKEN with actual values
curl -X POST http://127.0.0.1:9999/v3/sessions/SESSION_ID/cancel -H 'Authorization: Bearer TOKEN'
3

Submit a new turn

After cancelling, you can submit a new turn to continue the conversation.

Automatic timeout
Permission requests that are not resolved within 5 minutes are automatically denied by the daemon. The turn will receive a tool denial and continue without the tool result.

State File Corrupt

If the state file at ~/.config/opta/daemon/state.json becomes corrupt (e.g., due to a power loss during write), the CLI will fail to connect to the daemon.

Fix: delete the state file and restart the daemon.

Remove corrupt state and restart
rm ~/.config/opta/daemon/state.json && opta daemon start
Session data is safe
Deleting state.json only removes the daemon process metadata (PID, token, port). Your session history is stored separately in ~/.config/opta/daemon/sessions/ and will not be affected.

Crash Recovery

If the daemon crashes, the CLI automatically detects the stale state file on the next command. The ensureDaemonRunning crash guardian performs these steps:

  • Reads the PID from state.json
  • Sends a signal-zero check to verify the process is alive
  • If the process is dead, removes the stale state file
  • Spawns a new daemon with a fresh token
  • Retries the original command

This happens transparently — in most cases, you will see a brief delay while the daemon restarts, then your command proceeds normally.

opta doctor

The opta doctor command runs a comprehensive diagnostic check across the entire Opta Local stack:

opta doctor
Checking daemon...        ● running (pid 12345, port 9999)
Checking LMX...           ● reachable (192.168.188.11:1234)
Checking model...         ● loaded (qwen3-30b-a3b)
Checking config...        ● valid
Checking permissions...   ● ok

All checks passed.

Use opta doctor --fix to attempt automatic fixes for common issues (stale state files, dead processes, missing config directories):

Run diagnostics and auto-fix issues
opta doctor --fix

Log Analysis

The daemon log at ~/.config/opta/daemon/daemon.log is your primary debugging tool. Key patterns to look for:

text
# Successful start
[10:00:01] INFO  daemon started on 127.0.0.1:9999

# LMX connection failure
[10:00:05] ERROR lmx preflight failed: ECONNREFUSED 192.168.188.11:1234

# Permission timeout
[10:05:00] WARN  permission request perm_001 timed out (5m), auto-denying

# OOM in tool worker
[10:10:00] ERROR tool worker crashed: heap out of memory

# Session directory creation race
[10:00:02] WARN  session dir already exists, skipping mkdir

Reset Everything

As a last resort, you can perform a full daemon reset. This stops the daemon, removes all state files, and starts fresh. Session history is preserved.

Step 1: Stop the daemon
opta daemon stop
Step 2: Remove state and logs
rm ~/.config/opta/daemon/state.json ~/.config/opta/daemon/daemon.log
Step 3: Start fresh
opta daemon start
Do not delete the sessions directory
The ~/.config/opta/daemon/sessions/ directory contains all your persisted session data. Deleting it will permanently erase your conversation history.