[BUG] PTY leak: Claude desktop app accumulates ~490 /dev/ptmx file descriptors
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?
macOS 15.7.3
Claude Desktop Client
<img width="1170" height="742" alt="Image" src="https://github.com/user-attachments/assets/9274c654-97b8-4d23-8a71-d897bb917d64" />
After running for 4 days, lsof /dev/ptmx showed that the Claude process held 490 PTY FDs, exceeding the kern.tty.ptmx_max=511 limit, causing the system terminal to fail to open (forkpty: Device not configured). More detailed information is available here: https://douwen.me/en/archives/1206/
What Should Happen?
Claude does not encounter any errors even after a long period of time without being restarted.
Error Messages/Logs
[forkpty: Device not configured]
[Failed to create a new process and open a pseudo-terminal (pseudo-tty).]
Steps to Reproduce
This bug won't reproduce within five minutes; it requires time to accumulate. Based on observations on my machine, the typical triggering path is as follows:
First, the Claude desktop client runs continuously for several days without exiting. This is typical for moderately intensive users; many Macs restart more than a week apart.
Second, frequent use of Claude Code during this period, including opening sessions within the Claude application, launching Claude Code commands in an external terminal, running batch tasks in headless mode, etc. Each additional triggering scenario increases the frequency of PTY requests.
Third, other system applications occasionally use PTYs, such as iTerm, the Cursor's built-in terminal, and remote SSH. These will overlap with the Claude leak, accelerating the rate at which the bug reaches its limit.
After meeting the first two conditions, the 511 limit will be reached in approximately 3-5 days. The lsof results for this machine at the time of this report show that Claude holds 490 PTYs, and other processes occupy about 15, for a total of 505. This is only 6 away from the upper limit of 511, so opening a new terminal will almost certainly fail.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
v1.8089.1
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
More detailed information is available here: https://douwen.me/en/archives/1206/
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗