[BUG] Co-work Windows: sandbox environment leaks into child processes, breaking Unix domain socket IPC (JVM NIO, Gradle, MCP servers affected)

Status Fixed / completed
Maintainer reply None cached
Activity 7 comments · opened Apr 7, 2026 · closed May 26, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When any Claude Desktop for windows builds have cowork setup and working, any attempt by CC to create a process that needs a unix domain socket fails, because its running in the restrictive AppContainer environment.

Sample stack:

Caused by: java.io.IOException: Unable to establish loopback connection
	at java.base/sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:103)
	at java.base/sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:67)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
	at java.base/sun.nio.ch.PipeImpl.<init>(PipeImpl.java:198)
	at java.base/sun.nio.ch.WEPollSelectorImpl.<init>(WEPollSelectorImpl.java:78)
	at java.base/sun.nio.ch.WEPollSelectorProvider.openSelector(WEPollSelectorProvider.java:33)
	at java.base/java.nio.channels.Selector.open(Selector.java:295)
	at org.gradle.internal.remote.internal.inet.SocketConnection$SocketInputStream.<init>(SocketConnection.java:164)
	at org.gradle.internal.remote.internal.inet.SocketConnection.<init>(SocketConnection.java:62)
	... 34 more
Caused by: java.net.SocketException: Invalid argument: connect
	at java.base/sun.nio.ch.UnixDomainSockets.connect0(Native Method)
	at java.base/sun.nio.ch.UnixDomainSockets.connect(UnixDomainSockets.java:148)
	at java.base/sun.nio.ch.UnixDomainSockets.connect(UnixDomainSockets.java:144)
	at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:851)

What Should Happen?

CC should not be running bash commands in the AppContainer environment.

Error Messages/Logs

Steps to Reproduce

  1. Try to run a gradle process
  2. See error above.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

unknown

Claude Code Version

Claude 1.2.234 (2d1855) 2026-04-01T07:58:22.000Z

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

_No response_

View original on GitHub ↗

7 Comments

github-actions[bot] · 4 months ago

Found 1 possible duplicate issue:

  1. https://github.com/anthropics/claude-code/issues/41432

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

jsamczuk · 3 months ago

Hi, any update?

isamotiuc · 3 months ago

Same issue for me

jsamczuk · 3 months ago

I have figured it out, sharing my workaround (I use gitbash for windows):

Heads-up: Gradle / any JVM tool fails in Claude Code on Windows with "Unable to establish loopback connection"

What you'll see

Running Gradle (or any Java command) from Claude Code's terminal on Windows fails with:

java.io.IOException: Unable to establish loopback connection
Caused by: java.net.SocketException: Invalid argument: connect
at sun.nio.ch.UnixDomainSockets.connect0(Native Method)
Same command works fine in your normal PowerShell/Git Bash terminal. Sandbox exclusions don't help

Cause

JDK 17+ on Windows uses WEPollSelectorImpl, which opens an AF_UNIX socket for its internal wakeup pipe. The socket path is built from %TEMP%. Windows' AF_UNIX (and POSIX in general) caps sockaddr_un.sun_path at 108 bytes.

In a normal terminal %TEMP% resolves cleanly (C:\Users\<you>\AppData\Local\Temp\...) and fits. Inside Claude Code's Cowork VM sandbox, the path gets resolved through the overlay filesystem, which prepends an internal prefix — pushing the final path past 108 bytes. The kernel returns EINVAL, every JVM in the sandbox dies on startup. Not fixed in JDK 21 or 25; the limit is an OS-level kernel ABI, not a JVM-tunable.

Related: claude-code#41432.

Fix

Point TEMP/TMP at a short path. In ~/.claude/settings.json:

{
  "env": {
    "JS_CLAUDE": 1
  },
  "sandbox": {
    "filesystem": {
      "allowWrite": ["C:\\jtmp"]
    }
  }
}

Next, in your ~/.bashrc file add:

if [ -n "$JS_CLAUDE" ]; then
  # Runs only when bash is invoked by Claude Code
  export TMP=C:\\jtmp
  export TEMP=C:\\jtmp
fi

Note: you can't set TMP and TEMP env variables in your claude settings, because they're overriden by your system. bashrc loads last.

Then mkdir C:\jtmp and restart Claude Code. Gradle, Maven, plain java — all work again.

jsamczuk · 3 months ago

Hi, I see the issue is closed. Did you managed to shorten the temp path somehow? I know workaround, but it would be nice to fix it for all users, so they don't have to google it :)

TheBestPessimist · 3 months ago

This is very much NOT fixed!

There is a workaround, but the issue itself is not fixed

jrxpana · 1 month ago

THANK YOU @jsamczuk , my tycho builds wouldn't run using Claude Code mode in Claude Desktop, same error and same root cause. Your workaround worked and I don't think I would've figured that out on my own.

I also hope that this gets fixed in the desktop client itself, it's a pity this issue got closed without an actual fix in the tool itself.