Skip to content

Hook error blocking operations: Unable to connect to claude-mem service #717

Description

Hook error blocking operations: Unable to connect to claude-mem service

Problem Statement

Users are experiencing frequent UserPromptSubmit operation blocked by hook errors when Claude Code is working. The error indicates that the claude-mem plugin is unable to connect to its callback service, preventing it from saving observations and memory data. While this doesn't affect core Claude Code functionality, it disrupts the user experience with repeated error messages.

Environment

  • Claude-mem: 9.0.4
  • Claude Code: 2.0.74 (Claude Code)
  • Node.js: v20.19.4
  • Bun: 1.3.4
  • OS: Linux 6.14.0-37-generic (x64)
  • Platform: linux

Configuration Details

  • Plugin Path: ~/.claude/plugins/marketplaces/thedotmack
  • Data Directory: ~/.claude-mem
  • Database: ~/.claude-mem/claude-mem.db (exists, 11948.00 KB)
  • Worker Status: Running (PID: 214673, Port: 37777, Uptime: 8 minutes)
  • Active Sessions: 0
  • SSE Clients: 1

Key Settings

{
  "CLAUDE_MEM_MODEL": "claude-sonnet-4-5",
  "CLAUDE_MEM_WORKER_PORT": 37777,
  "CLAUDE_MEM_WORKER_HOST": "127.0.0.1",
  "CLAUDE_MEM_LOG_LEVEL": "INFO",
  "CLAUDE_MEM_CONTEXT_OBSERVATIONS": 50
}

Steps to Reproduce

  1. Enable the claude-mem plugin in Claude Code
  2. Use Claude Code for normal operations (any prompt submission)
  3. Observe repeated hook errors during operation

Actual Behavior

The following error appears repeatedly during Claude Code operations:

UserPromptSubmit operation blocked by hook:
  Hook error: Error: Unable to connect. Is the computer able to access the url?
  Original prompt: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Investigation shows:

  • The claude-mem plugin is enabled in settings: "claude-mem@thedotmack": true
  • The plugin attempts to call a callback URL after each action to save observations/memory
  • The callback service is unreachable despite the worker showing as "Running"
  • Database exists and appears to have data (11.9 MB)

Expected Behavior

The claude-mem plugin should either:

  1. Successfully connect to the callback service without errors, OR
  2. Gracefully handle connection failures without blocking operations or showing repeated errors

Root Cause Identified

The worker service PID becomes stale/mismatched with the actual running process. The ~/.claude-mem/worker.pid file contains an old PID while a different worker process is running, causing connection failures.

For example:

  • worker.pid shows PID 268641
  • Actual running process is PID 267376
  • This mismatch causes the hooks to fail to connect

Workaround

Restarting the worker service resolves the issue:

# 1. Kill the existing worker process
pkill -f "worker-service.cjs"

# 2. Restart the worker manually
cd ~/.claude/plugins/cache/thedotmack/claude-mem/9.0.4 && bun scripts/worker-service.cjs start

# 3. Verify it's working
curl -s http://127.0.0.1:37777/api/readiness
# Should return: {"status":"ready","mcpReady":true}

After restarting, hooks execute successfully without connection errors.

Suggested Fix

The plugin should:

  1. Detect stale PID files and auto-recover
  2. Verify the worker process is actually running before attempting connections
  3. Implement a health check retry mechanism before failing hooks

Contact

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions