PTY allocation request failed on channel 0

20/02/2009

Yesterday, I was trying to login to my machine and I got the following message:

PTY allocation request failed on channel 0

My prompt was stuck and I could not enter commands. This happened because -for some reason- the tty related devices(/dev/ptmx, /dev/pts) were not created or mounted on my machine. In order to get this problem resolved, I created and mounted the missing devices using the following commands:

rm -rf /dev/ptmx
mknod /dev/ptmx c 5 2
chmod 666 /dev/ptmx
umount /dev/pts
rm -rf /dev/pts
mkdir /dev/pts
mount /dev/pts

In order to be able to execute commands you will have to login to your machine(isn’t this supposed to be the original problem :) ).
This will do the trick:

ssh user@host "/bin/bash -i"

My VPS is built on openVZ but I have seen this problem occur also in XEN machines.
Leave me a comment if this works for you!

There are 39 comments in this article:

  1. 11/04/2009spott say:

    Thanks for tip. Its work to me also. I have the similar problem with my OpenVZ VPS today.

  2. 12/05/2009toto say:

    YEAH
    WOrked for me too.
    thank you very much !

  3. 14/05/2009Thomas Krichel say:

    Yes, have the same issue. I think I cleared pty or something like that last time it happened. But your bash -i gets me into the box!

  4. 1/06/2009Zerial say:

    mount /dev/pts: Can’t found /dev/pts on /etc/fstab or /etc/mstab

    Now, I don’t have tty.

  5. 1/06/2009Zerial say:

    I’ve solved it adding:

    none /dev/pts devpts defaults 0 0

    into /etc/fstab

    thanks

  6. 9/06/2009itsec say:

    I needed to install install package udev in domU to get it working.

  7. 21/06/2009Saravia say:

    Just what I was looking for. Thank you! Bookmark added for sure :D

  8. 24/06/2009Jason Liu say:

    Thanks for the post. This works on my CentOS machine too.

  9. 12/08/2009rc say:

    YOU SAVED MY LIFE!!! THANKS!!!

  10. 4/10/2009J. Piel say:

    user@host “/bin/bash -i” <– Freaking Brilliant!
    This got my ptmx created, but it was gone on the next reboot. No matter, I was able to get work done until my VPS provider fixed it.

    Thank you much for sharing the knowledge!

  11. 15/11/2009joo say:

    BRILLIANT. Thanks!!

  12. 12/12/2009Create Centos5 DomU on Debian Etch Dom0 » 月影鹏鹏 say:

    [...] Booted up ok then. More issues however with "PTY allocation request failed on channel 0". Reading http://www.asteriosk.gr/blog/2009/02/20/pty-allocation-request-failed-on-channel-0/ including the comments got that resolved. I could ssh in ok, but the xm console did not work. More [...]

  13. 21/01/2010Sebastian say:

    THX!

    Great!

    I had this Problem after changing the broken disk of a mdadm raid1 on a real system.

  14. 28/01/2010JamesGT say:

    This worked for me also, but I had to ad the line to the fstab file as indicated by Zerial. This was on a Slackware VPS with OpenVZ.

    This started when I upgraded Slackware 12 to 12.2 in OpenVZ via slackpkg. Looks to be good now.

    Thanks!

  15. 7/02/2010Craig Nakamoto say:

    Thanks, this worked for me too on an older server running CentOS 4.2.

  16. 18/02/2010dude say:

    thanks a bunch, my vps provider doesn’t support archlinux so I’m glad to have found this fix! cheers

  17. 20/02/2010Nepto say:

    Thank you. You just saved my ass ;-)

  18. 12/03/2010Dongsheng say:

    Thanks a lot!

    fixed my problem :-)

  19. 25/03/2010PTY allocation request failed on channel 0 « Big fish say:

    [...] 了一下,有个大叔已经研究出了怎么修复,用 `ssh user@dongsheng.org ‘/bin/bash -i’` 进去,重新挂载 /dev/pts [...]

  20. 9/04/2010Quintilio say:

    Many Thanks for your guide.
    I have solve a problem with my Giganas
    Cheers
    Quintilio

  21. 15/04/2010flinks say:

    your guide plus de add made for zerial solved here.
    Thank you.

  22. 23/04/2010Rob say:

    That did the trick – I’m going to re-post on my site, with a link here.
    That was ANNOYING!

    Thanks, Yak! You saved me the hassle of trying to deal with VPS resellers who don’t know all that much. :)

  23. 30/06/2010Rob say:

    Zerial fix worked for me.

  24. 7/09/2010Arul say:

    it works for me.. thanks

  25. 8/10/2010(solved) git on cygwin177 | Javouhey's Blog say:

    [...] post about the PTY problem This entry was posted in tools and tagged cygwin, git. Bookmark the permalink. ← [...]

  26. 21/10/2010Rob Thomson » PTY allocation request failed on channel 0 in OpenVZ say:

    [...] http://blog.asteriosk.gr/2009/02/20/pty-allocation-request-failed-on-channel-0/ [...]

  27. 13/12/2010up to you say:

    It seems to me, what is it it was already discussed.

  28. 4/01/2011PTKDev say:

    root@ptk-debian:/dev/pts# umount /dev/pts
    umount: /dev/pts: device is busy.
    (In some cases useful info about processes that use
    the device is found by lsof(8) or fuser(1))

  29. 10/01/20111dan say:

    Had this crop up on a CentOS/Kloxo VPS I just set up about a month ago. Must have snuck in with one of the yum updates.

  30. 21/01/2011emwphov say:

    Tanks for solving my problem (clever trick with bash -i). The error message depends on access tool, so I add these for the search robots:
    – Putty: “Server refused to allocate pty”
    – Tunnelier: “Server does not support xterm terminal”
    – Local console: “PTY allocation request failed on channel 0″

    Other things to check:
    – /etc/fstab should contain /dev/pts
    – Have you ran out of pty:s? Check with “who” command and compare to /proc/sys/kernel/pty/max

  31. 28/02/2011Namaless say:

    Thanks, works all fine for me ^_^

  32. 3/03/2011Robert say:

    Thank you, that saved my day.

  33. 7/04/2011Miguelitic say:

    Thanks!!!, I use dd-wrt on WRT160NL, and I solved the problem:

    #ssh user@192.168.x.x “/bin/ash -i”

  34. 2/07/2011SandUhrGucker say:

    Thank you much for the time i can save now!

  35. 6/10/2011PTY allocation request failed on channel 0 « exemen 's blog say:

    [...] to your machine(isn’t this supposed to be the original problem ). This will do the trick: view sourceprint? 1.ssh user@host "/bin/bash [...]

  36. 23/10/2011Christian say:

    You rock! Quick and to the point to solve my issue on my OpenFiler box!

  37. 17/11/2011nackox say:

    Thanks for the tip. Yesterday I though on creating a new XEN service and the problem came up. Resolved :)

  38. 19/11/2011Amit say:

    Hi Yak,
    Can you suggest any solution for cygwin/copssh? I couldn’t find any answer for cygwin/copssh.

    Thanks,
    Amit

  39. 24/01/2012Drew say:

    Zerial say:

    mount /dev/pts: Can’t found /dev/pts on /etc/fstab or /etc/mstab

    Now, I don’t have tty.

    1/06/2009Zerial say:

    I’ve solved it adding:

    none /dev/pts devpts defaults 0 0

    into /etc/fstab

    thanks
    —————–
    however im unable to edit the fstab in this mode, im getting this:
    [root@alarm ~]# vi /etc/fstab
    vi /etc/fstab
    [Using open mode]

    Open and visual must be used interactively
    —–
    How might i add this to the fstab as im unable to “mount /dev/pts”

    Thanks

    Drew

Write a comment: