claude-code - 💡(How to fix) Fix Claude Code leaks pty handles — exhausts pseudo-terminals on macOS after long session

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

After a long Claude Code session with many Bash tool calls, the Claude process accumulates hundreds of open pseudo-terminal (pty) handles without releasing them. This eventually exhausts the macOS pty pool, causing all new terminal windows/tabs to fail with:

[forkpty: Device not configured]
[Could not create a new process and open a pseudo-tty.]

Root Cause

After a long Claude Code session with many Bash tool calls, the Claude process accumulates hundreds of open pseudo-terminal (pty) handles without releasing them. This eventually exhausts the macOS pty pool, causing all new terminal windows/tabs to fail with:

[forkpty: Device not configured]
[Could not create a new process and open a pseudo-tty.]

Fix Action

Workaround

Quit and relaunch Claude Code — this releases all handles.

Code Example

[forkpty: Device not configured]
[Could not create a new process and open a pseudo-tty.]

---

lsof | grep ptmx | awk '{print $1}' | sort | uniq -c | sort -rn | head -10
RAW_BUFFERClick to expand / collapse

Summary

After a long Claude Code session with many Bash tool calls, the Claude process accumulates hundreds of open pseudo-terminal (pty) handles without releasing them. This eventually exhausts the macOS pty pool, causing all new terminal windows/tabs to fail with:

[forkpty: Device not configured]
[Could not create a new process and open a pseudo-tty.]

Reproduction

Run a long Claude Code session with many Bash tool calls, then:

lsof | grep ptmx | awk '{print $1}' | sort | uniq -c | sort -rn | head -10

Output showed 511 pty handles held by the Claude process — enough to prevent any new terminal from opening.

Environment

  • macOS 26.5 (Build 25F71, Darwin 25.5.0)
  • Claude Code desktop app

Expected behaviour

Pty handles should be released after each Bash tool call completes.

Actual behaviour

Handles accumulate across the session until the pty pool is exhausted.

Workaround

Quit and relaunch Claude Code — this releases all handles.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Claude Code leaks pty handles — exhausts pseudo-terminals on macOS after long session