claude-code - 💡(How to fix) Fix Claude desktop leaks PTY file descriptors, exhausting system PTY limit

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…

The Claude desktop app leaks PTY (pseudo-terminal) master file descriptors over time. Each bash tool call opens /dev/ptmx but the handles are never closed when the session ends. This causes the system-wide PTY pool to be exhausted, breaking other terminal applications.

Error Message

  • Ghostty version: reported in error message

Root Cause

The Claude desktop app leaks PTY (pseudo-terminal) master file descriptors over time. Each bash tool call opens /dev/ptmx but the handles are never closed when the session ends. This causes the system-wide PTY pool to be exhausted, breaking other terminal applications.

Fix Action

Workaround

Quit and relaunch the Claude desktop app to release all leaked handles.

Code Example

$ lsof 2>/dev/null | grep "ptmx" | awk '{print $1, $2}' | sort | uniq -c | sort -rn | head -5
 513 Claude 60807     ← nearly all PTYs consumed by Claude desktop
   3 wezterm-g 99670
   3 Safari 14780
   ...

---

$ sysctl kern.tty.ptmx_max
kern.tty.ptmx_max: 511
RAW_BUFFERClick to expand / collapse

Summary

The Claude desktop app leaks PTY (pseudo-terminal) master file descriptors over time. Each bash tool call opens /dev/ptmx but the handles are never closed when the session ends. This causes the system-wide PTY pool to be exhausted, breaking other terminal applications.

Impact

  • Ghostty fails to open new terminal windows with: "Your system cannot allocate any more pty devices."
  • Zellij fails to start with: "could not enable raw mode: Os { code: 6, kind: Uncategorized, message: "Device not configured" }"
  • Any app that requires PTY allocation is affected.

Reproduction

Use Claude desktop with the bash tool across multiple sessions/conversations over time. The PTY count grows monotonically.

Evidence

$ lsof 2>/dev/null | grep "ptmx" | awk '{print $1, $2}' | sort | uniq -c | sort -rn | head -5
 513 Claude 60807     ← nearly all PTYs consumed by Claude desktop
   3 wezterm-g 99670
   3 Safari 14780
   ...
$ sysctl kern.tty.ptmx_max
kern.tty.ptmx_max: 511

513 open PTY masters in a single Claude process against a system limit of 511.

Workaround

Quit and relaunch the Claude desktop app to release all leaked handles.

Environment

  • macOS Darwin 25.4.0 (Apple Silicon, J614s)
  • Claude desktop version: 2.1.136
  • Ghostty version: reported in error message

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