The system has no more ptys? How to fix it.

Danila Vershinin
Sep 4, 2018 · 1 min read

Maybe you’re like me and using an expect script that works in one machine and fails in another. Or maybe you're doing something else but still getting this error:

Problem: The system has no more ptys. Ask your system administrator to create more.

Google search returns weird advices from Linux from Scratch followers. But we are using stock CentOS 7.

It comes out that things are related to mount options of devpts (which maybe different between different hosting providers). Try to run cat /proc/mounts.

In a machine with the problem, you would see something like this:

devpts /dev/pts devpts rw,relatime,mode=600,ptmxmode=000 0 0

Where as the same script will run fine on a machine with:

devpts /dev/pts devpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0

So what you need is to ensure that devpts is mounted with mode 620 for things to work smoothly.
Fire up your favorite terminal editor and make sure that devpts entry is such:

devpts /dev/pts devpts defaults,gid=5,mode=620 0 0

You have to either change the existing one or add new entry, if it’s not present.

Apply the change with:

mount /dev/pts -o remount

Now back to writing scripts, you Linux hacker :)

Danila Vershinin
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade