Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm running tmux and creating many sessions to various servers. After opening 128, I can no longer open new ones, or open new tabs in Terminal. The error messages is:

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

Is there any way I can increase the number of ptys?

share|improve this question
    
It'd be helpful to know what version of OS X you're running, and what kind of Mac, and particularly, how much RAM you have installed. –  gosmond Feb 20 '13 at 6:13
    
I'm using 10.8.2 and have 8gb of RAM, which should be more than enough to open thousands of ssh sessions. –  Steve Wills Mar 2 '13 at 22:45

1 Answer 1

up vote 7 down vote accepted

(Tested on OS X 10.8.2; other releases may be slightly different.)

You can change the system’s limit on ptys with the sysctl command.

sudo sysctl -w kern.tty.ptmx_max=255

This should immediately let you open more ptys.

To set this automatically after each reboot, put the following line in the /etc/sysctl.conf file:

kern.tty.ptmx_max=255

(Note: I did not try this, but, from a look at the source code, it looks like launchd does process this file.)

This file may not exist; if you have to create it, you should probably be sure it has restricted ownership and permissions:

sudo chown root:wheel /etc/sysctl.conf
sudo chmod 644 /etc/sysctl.conf

Eventually, you may run into some other per-process or per-user resource limits (e.g. total number of processes per user, and total number of open file descriptors per process).

share|improve this answer
    
Eventually got to test this, works great, thanks. For the record, I couldn't set this above 999, but that will do for now. –  Steve Wills Mar 2 '13 at 22:44
    
This allows me to open up to 169 ptys, but not more. sudo sysctl kern.tty.ptmx_max returns 999 which is correct. Anything I'm missing on this one? –  ubuntudroid Apr 12 '13 at 9:16
    
@ubuntudroid: You might be running into a limit on the number of open files (ulimit in bash). These kinds of limits are inherited from parent processes, so to change it for tmux you will need to change it in (e.g.) a shell and then restart your tmux server. To make the change “persistent”, try a launchctl.conf that uses a limit command. –  Chris Johnsen Apr 12 '13 at 18:44
    
Whenever inside tmux on my Mac (10.9.4) i noticed ulimit -a reported a 256 file descriptor limit. Calling ulimit -n 2000 totally worked though. –  Steven Lu Sep 2 at 17:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.