---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://framesfield.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
title: "Fix Blender 3D MCP Socket Connection Refused Errors"
description: "Open Blender Desktop, enable addon.py, press N in the 3D Viewport to click Start MCP Server on port 9876, kill duplicate Blender listeners via lsof, pin BLENDER_HOST=127.0.0.1 and BLENDER_PORT=9876, and verify TCP reachability with nc before prompting."
canonical: "https://framesfield.com/fixes/blender-mcp-socket-connection-refused-port-fix"
---

# Fix Blender 3D MCP Socket Connection Refused Errors

> Open Blender Desktop, enable addon.py, press N in the 3D Viewport to click Start MCP Server on port 9876, kill duplicate Blender listeners via lsof, pin BLENDER_HOST=127.0.0.1 and BLENDER_PORT=9876, and verify TCP reachability with nc before prompting.

- **Canonical URL:** https://framesfield.com/fixes/blender-mcp-socket-connection-refused-port-fix
- **Category:** Agents, MCP & Design-to-Code
- **Error Signature:** `ConnectionRefusedError: [Errno 61] Connection refused (127.0.0.1:9876) | Could not connect to Blender. Make sure the Blender addon is running | OSError: [Errno 48] Address already in use on port 9876`
- **Last Verified:** 2026-12-01

## Observed Symptom

Your coding agent invokes get_scene_info or execute_blender_code through mcp-for-blender, and every command fails immediately with Connection refused on port 9876—or hangs and times out while modifying the wrong Blender scene window.

## Technical Root Cause

Blender MCP operates as a two-process local TCP bridge: uvx mcp-for-blender runs only the stdio proxy, while Blender Desktop must stay open with addon.py enabled and its socket server toggled ON in the 3D Viewport N-sidebar on the exact same IPv4 host (127.0.0.1) and port (9876) with no zombie Blender instance occupying that port.

## Under the Hood

Most first-time Blender MCP failures stem from expecting uvx mcp-for-blender to launch Blender automatically. In reality, ahujasid/mcp-for-blender consists of two separate pieces: an external Python MCP server launched by Claude Code, Cursor, or Claude Desktop over stdio, and a lightweight TCP socket listener running inside an open Blender Desktop GUI via addon.py on 127.0.0.1:9876. Installing the add-on checkbox inside Blender Preferences is not enough—after every fresh Blender launch, you must press N in the 3D Viewport, open the BlenderMCP sidebar tab, and click Start MCP Server / Connect to Claude to open TCP port 9876.

Even when the add-on server is running, two subtle networking conflicts trigger instant failures on macOS and Windows. First, passing BLENDER_HOST=localhost can resolve to IPv6 ::1 while Blender’s Python socket bound strictly to IPv4 127.0.0.1, producing a false ConnectionRefusedError; pinning BLENDER_HOST=127.0.0.1 removes IPv6 ambiguity completely. Second, opening a second Blender window while a minimized or hung Blender process already holds port 9876 causes OSError: [Errno 48] Address already in use—or silently routes every agent camera edit into the forgotten background .blend file instead of your active viewport.

A final failure mode mimics a dropped socket: executing heavy 512-sample Cycles renders or high-poly boolean modifiers synchronously inside execute_blender_code blocks Blender’s single-threaded bpy UI timer beyond the socket read timeout. Keeping interactive camera blocking on EEVEE Next or 32-sample Cycles previews—and keeping your installed addon.py version synced with uvx mcp-for-blender (migrated from legacy blender-mcp)—keeps every 3D scene call fast and deterministic.

## Before vs. After

### Broken (Broken Setup (Closed Bridge / Legacy Package / Ambiguous IPv6 localhost))

```
{
  "mcpServers": {
    "blender-mcp": {
      "command": "uvx",
      "args": ["blender-mcp"],
      "env": {
        "BLENDER_HOST": "localhost"
      }
    }
  }
}
// Fails if Blender N-panel server is OFF, ::1 refuses IPv4 socket, or stale Blender holds 9876
```

### Verified Fix (Verified Bridge (Current mcp-for-blender + Explicit IPv4 127.0.0.1:9876))

```
# 1. In Blender 3D Viewport -> press N -> BlenderMCP tab -> click "Connect to Claude" (Port 9876)
# 2. Pin current PyPI package, absolute uvx path, and explicit IPv4 host/port in mcp.json:
{
  "mcpServers": {
    "blender-mcp": {
      "command": "/opt/homebrew/bin/uvx",
      "args": ["mcp-for-blender"],
      "env": {
        "BLENDER_HOST": "127.0.0.1",
        "BLENDER_PORT": "9876",
        "PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
      }
    }
  }
}
```

Using the current mcp-for-blender package with explicit IPv4 127.0.0.1:9876 eliminates localhost IPv6 resolution mismatches and guarantees the MCP proxy targets your active Blender viewport socket.

## Copy-Paste Fix (diagnose-blender-mcp.sh)

```bash
#!/usr/bin/env bash
set -euo pipefail

HOST="${BLENDER_HOST:-127.0.0.1}"
PORT="${BLENDER_PORT:-9876}"

echo "=== 1. Checking which process is listening on TCP ${HOST}:${PORT} ==="
if command -v lsof >/dev/null 2>&1; then
  lsof -nP -iTCP:"$PORT" -sTCP:LISTEN || echo "NOTHING listening on port ${PORT} — open Blender -> N sidebar -> BlenderMCP -> Start Server!"
else
  ss -tlnp 2>/dev/null | grep ":${PORT} " || echo "NOTHING listening on port ${PORT}"
fi

echo ""
echo "=== 2. Checking for duplicate Blender processes (port conflict guard) ==="
pgrep -fl "[B]lender" || echo "No running Blender Desktop process detected."

echo ""
echo "=== 3. Sending live read-only get_scene_info JSON probe to Blender socket ==="
python3 - <<PY
import json, socket, sys

host = "${HOST}"
port = int("${PORT}")
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(4.0)
try:
    sock.connect((host, port))
    payload = json.dumps({"type": "get_scene_info", "params": {}}).encode("utf-8")
    sock.sendall(payload)
    chunks = []
    while True:
        try:
            data = sock.recv(8192)
            if not data:
                break
            chunks.append(data)
            try:
                parsed = json.loads(b"".join(chunks).decode("utf-8"))
                print("PASS: Blender socket responded cleanly ->", json.dumps(parsed)[:240])
                sys.exit(0)
            except json.JSONDecodeError:
                continue
        except socket.timeout:
            break
    print("WARN: Connected to port", port, "but received incomplete/empty JSON response.")
    sys.exit(1)
except ConnectionRefusedError:
    print(f"FAIL: Connection refused at {host}:{port}. Press N in Blender -> BlenderMCP -> Connect/Start Server.")
    sys.exit(1)
finally:
    sock.close()
PY
```

## Step-by-Step Resolution

1. **Verify Blender Desktop is open and the N-sidebar MCP socket server is active:** Open your target .blend file in Blender 3.0+, confirm the latest addon.py from ahujasid/mcp-for-blender is checked under Preferences -> Add-ons, press N in the 3D Viewport, open the BlenderMCP tab, and click Start Server / Connect to Claude.
2. **Clear duplicate Blender processes holding port 9876 and pin IPv4 127.0.0.1:** Run lsof -nP -iTCP:9876 -sTCP:LISTEN to verify exactly ONE Blender instance owns port 9876, close any stray background Blender windows, and set BLENDER_HOST=127.0.0.1 plus BLENDER_PORT=9876 in your MCP config.
3. **Run the direct Python socket probe before reconnecting Claude Code or Cursor:** Execute diagnose-blender-mcp.sh to prove Blender replies to get_scene_info directly over TCP; once it prints PASS, restart your MCP client using uvx mcp-for-blender and run your camera-blocking prompt.

## Verification Check (Confirm Single Blender Listener on 127.0.0.1:9876 & Valid Scene JSON Reply)

```bash
lsof -nP -iTCP:9876 -sTCP:LISTEN && bash diagnose-blender-mcp.sh
```

**Expected healthy output:**

```text
Blender   48210 user   42u  IPv4 ... TCP 127.0.0.1:9876 (LISTEN)
PASS: Blender socket responded cleanly -> {"status": "success", "result": {"name": "Scene", "object_count": 3, ...}}
```

## Prevention Guardrails

1. **Keep addon.py and uvx mcp-for-blender updated from the same release:** Running a six-month-old addon.py inside Blender against a freshly pulled uvx mcp-for-blender proxy causes silent JSON command mismatches and socket timeouts.
2. **Keep viewport renders lightweight during interactive MCP sessions:** Use EEVEE Next or 32–64 sample Cycles previews while iterating camera focal lengths (35mm/50mm/85mm) over MCP, and kick off heavy 4K final renders asynchronously or via blender -b CLI.
3. **Save a versioned backup .blend before allowing autonomous bpy scripts:** Blender MCP executes arbitrary bpy Python inside your live scene—saving scene_v01.blend before agent edits guarantees instant rollback if a lighting or mesh script goes sideways.

## FAQs

### Does Blender have to stay open on screen while Claude Code or Cursor uses Blender MCP?

Yes. The MCP add-on runs inside Blender’s main application timer loop to mutate the live scene safely on the main thread. Closing Blender shuts down TCP port 9876 immediately.

### Can I run two different Blender scenes on two different MCP ports at the same time?

Yes. Change the port number in the second Blender window’s BlenderMCP sidebar (for example to 9877) before clicking Start Server, and point a second MCP config entry at BLENDER_PORT=9877.

### Why does execute_blender_code time out right when I ask the agent to render a Cycles frame?

Calling bpy.ops.render.render(write_still=True) blocks Blender’s main thread until rendering completes. If Cycles takes 90 seconds on CPU, the MCP socket times out—enable Metal/CUDA GPU rendering, drop preview samples to 32, or use EEVEE Next.

### Should I configure uvx blender-mcp or uvx mcp-for-blender in mcp.json?

Use uvx mcp-for-blender. The upstream ahujasid/mcp-for-blender repository migrated its primary PyPI distribution to mcp-for-blender, while blender-mcp remains a legacy compatibility alias.

### Could macOS Firewall or VPN software block 127.0.0.1:9876?

Standard macOS Application Firewall allows loopback 127.0.0.1 traffic, but strict corporate endpoint proxies or Little Snitch rules occasionally intercept Python/Blender local sockets. Running the direct Python probe in diagnose-blender-mcp.sh immediately isolates local firewall blocks from MCP client errors.
