Fix 'Please free up some pty devices' on macOS
Fix “Please free up some pty devices” on macOS
If you’re running tools that spawn many subprocesses (AI agents, tmux sessions, SSH connections), you may hit the default pseudo-terminal (pty) limit on macOS.
Check your current limit
| |
Default is 511. Check how many are in use:
| |
If the count is near or above the max, you’re out of ptys.
Increase the limit
The maximum accepted value depends on your macOS / Darwin version. Try in order:
| |
If that returns “Invalid argument”, fall back to 512:
| |
Note: On Darwin 24.x (macOS 15 Sequoia), the kernel rejects values above a hard cap (e.g. 1023 fails). Use the highest value your system accepts.
This takes effect immediately. No reboot needed.
Make it persistent
Create or append to /etc/sysctl.conf so the setting survives reboots (use whichever value worked above):
| |
Clean up stale processes
Orphaned processes can hold ptys open. Find them:
| |
Kill anything you don’t recognize or no longer need:
| |
Verify
| |
That’s it. You’re back in business.
R