{"id":865,"date":"2026-05-20T09:19:15","date_gmt":"2026-05-20T09:19:15","guid":{"rendered":"https:\/\/arizu.id\/blog\/?p=865"},"modified":"2026-05-20T09:21:53","modified_gmt":"2026-05-20T09:21:53","slug":"fix-server-refused-allocate-pty-ssh-error","status":"publish","type":"post","link":"https:\/\/arizu.id\/blog\/fix-server-refused-allocate-pty-ssh-error\/","title":{"rendered":"How to Fix Server Refused to Allocate PTY and SSH Errors","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p data-path-to-node=\"5\">Managing a VPS or dedicated server is usually smooth sailing\u2014until you are suddenly locked out of your own terminal. If you are reading this, chances are you are staring at a frozen SSH screen right now, feeling a mild sense of panic as your keystrokes fail to register or return strange permission errors. But don&#8217;t worry! You are not alone, and more importantly, your server is not completely broken. In this technical guide, I will walk you through a quick, remote fix to bypass the frustrating &#8216;Server refused to allocate pty&#8217; error and get your command line back up and running in minutes<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_69_1 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/arizu.id\/blog\/fix-server-refused-allocate-pty-ssh-error\/#How_to_Fix_%E2%80%9CServer_Refused_to_Allocate_PTY%E2%80%9D_and_Frozen_SSH_Terminal\" title=\"How to Fix &#8220;Server Refused to Allocate PTY&#8221; and Frozen SSH Terminal\">How to Fix &#8220;Server Refused to Allocate PTY&#8221; and Frozen SSH Terminal<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/arizu.id\/blog\/fix-server-refused-allocate-pty-ssh-error\/#Understanding_the_Problem_Why_Does_the_Terminal_Freeze\" title=\"Understanding the Problem: Why Does the Terminal Freeze?\">Understanding the Problem: Why Does the Terminal Freeze?<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/arizu.id\/blog\/fix-server-refused-allocate-pty-ssh-error\/#The_Solution_Executing_Remote_Commands_via_SSH\" title=\"The Solution: Executing Remote Commands via SSH\">The Solution: Executing Remote Commands via SSH<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/arizu.id\/blog\/fix-server-refused-allocate-pty-ssh-error\/#Step_1_Restore_devnull_Permissions\" title=\"Step 1: Restore \/dev\/null Permissions\">Step 1: Restore \/dev\/null Permissions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/arizu.id\/blog\/fix-server-refused-allocate-pty-ssh-error\/#Step_2_Fix_devptmx_and_Mount_the_Terminal\" title=\"Step 2: Fix \/dev\/ptmx and Mount the Terminal\">Step 2: Fix \/dev\/ptmx and Mount the Terminal<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/arizu.id\/blog\/fix-server-refused-allocate-pty-ssh-error\/#Clean_Up_and_Security_Best_Practices\" title=\"Clean Up and Security Best Practices\">Clean Up and Security Best Practices<\/a><\/li><\/ul><\/nav><\/div>\n<h1 data-path-to-node=\"5\"><span class=\"ez-toc-section\" id=\"How_to_Fix_%E2%80%9CServer_Refused_to_Allocate_PTY%E2%80%9D_and_Frozen_SSH_Terminal\"><\/span>How to Fix &#8220;Server Refused to Allocate PTY&#8221; and Frozen SSH Terminal<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p data-path-to-node=\"6\">Have you ever successfully logged into your VPS via SSH, only to find that you cannot type a single command? Your terminal freezes, the text you type cascades downwards like a staircase, and you might see a barrage of errors like this:<\/p>\n<blockquote data-path-to-node=\"7\">\n<p data-path-to-node=\"7,0\"><code data-path-to-node=\"7,0\" data-index-in-node=\"0\">\/etc\/profile: line 70: \/dev\/null: Permission denied<\/code><\/p>\n<\/blockquote>\n<p data-path-to-node=\"8\">Or worse, your SSH client strictly rejects you with:<\/p>\n<blockquote data-path-to-node=\"9\">\n<p data-path-to-node=\"9,0\"><code data-path-to-node=\"9,0\" data-index-in-node=\"0\">PTY allocation request failed on channel 0<\/code> <code data-path-to-node=\"9,0\" data-index-in-node=\"43\">Server refused to allocate pty<\/code><\/p>\n<\/blockquote>\n<p data-path-to-node=\"10\">Do not panic. Your server is not completely dead, and you do not necessarily need to reinstall the OS. This is a common issue caused by missing or corrupted permissions in your Linux system&#8217;s device nodes\u2014specifically <code data-path-to-node=\"10\" data-index-in-node=\"218\">\/dev\/null<\/code> and <code data-path-to-node=\"10\" data-index-in-node=\"232\">\/dev\/ptmx<\/code>.<\/p>\n<p data-path-to-node=\"11\">Since you cannot interact with the server from the inside, you will need to force a fix from the outside. Here is the complete guide on how to resolve this issue.<\/p>\n<h1 data-path-to-node=\"12\"><span class=\"ez-toc-section\" id=\"Understanding_the_Problem_Why_Does_the_Terminal_Freeze\"><\/span>Understanding the Problem: Why Does the Terminal Freeze?<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p data-path-to-node=\"13\">To understand the fix, you need to understand what broke. When you connect via SSH, the Linux server assigns you a <b data-path-to-node=\"13\" data-index-in-node=\"115\">Pseudo-Terminal (PTY)<\/b>\u2014a virtual screen that bridges your keystrokes with the server&#8217;s shell.<\/p>\n<ul data-path-to-node=\"14\">\n<li>\n<p data-path-to-node=\"14,0,0\"><b data-path-to-node=\"14,0,0\" data-index-in-node=\"0\"><code data-path-to-node=\"14,0,0\" data-index-in-node=\"0\">\/dev\/ptmx<\/code> (Pseudo-Terminal Master Multiplexer):<\/b> This file is responsible for creating these virtual terminals. If its permissions are altered or the file is accidentally deleted, the server simply cannot generate a terminal interface for you, resulting in the &#8220;Server refused to allocate pty&#8221; error.<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"14,1,0\"><b data-path-to-node=\"14,1,0\" data-index-in-node=\"0\"><code data-path-to-node=\"14,1,0\" data-index-in-node=\"0\">\/dev\/null<\/code> (The Black Hole):<\/b> This is where Linux scripts send unwanted output. When logging in, background scripts (like <code data-path-to-node=\"14,1,0\" data-index-in-node=\"120\">\/etc\/bashrc<\/code> or <code data-path-to-node=\"14,1,0\" data-index-in-node=\"135\">\/etc\/profile<\/code>) try to write to <code data-path-to-node=\"14,1,0\" data-index-in-node=\"165\">\/dev\/null<\/code>. If this file&#8217;s permissions are broken, these scripts fail aggressively, causing permission denied loops that freeze the shell entirely.<\/p>\n<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"The_Solution_Executing_Remote_Commands_via_SSH\"><\/span>The Solution: Executing Remote Commands via SSH<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p data-path-to-node=\"16\">Because your interactive shell is broken, we have to bypass it. We will use SSH to pass commands directly to the server without requesting a terminal interface.<\/p>\n<p data-path-to-node=\"17\">Close your frozen SSH session (like PuTTY or your local terminal). Open a fresh Command Prompt, PowerShell, or local Terminal on your computer, and run the following two steps.<\/p>\n<h3 data-path-to-node=\"18\"><span class=\"ez-toc-section\" id=\"Step_1_Restore_devnull_Permissions\"><\/span>Step 1: Restore \/dev\/null Permissions<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p data-path-to-node=\"19\">First, we need to stop the background scripts from failing by recreating <code data-path-to-node=\"19\" data-index-in-node=\"73\">\/dev\/null<\/code> with the correct format and global write permissions.<\/p>\n<p data-path-to-node=\"20\">Run the following command from your local machine. <i data-path-to-node=\"20\" data-index-in-node=\"51\">(Note: Replace <code data-path-to-node=\"20\" data-index-in-node=\"66\">user<\/code>, <code data-path-to-node=\"20\" data-index-in-node=\"72\">YOUR_SERVER_IP<\/code>, and <code data-path-to-node=\"20\" data-index-in-node=\"92\">YOUR_PASSWORD<\/code> with your actual server credentials).<\/i><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ssh user@YOUR_SERVER_IP \"echo 'YOUR_PASSWORD' | sudo -S su -c 'rm -f \/dev\/null &amp;&amp; mknod -m 0666 \/dev\/null c 1 3'\"<\/pre>\n<p data-path-to-node=\"22\"><b data-path-to-node=\"22\" data-index-in-node=\"0\">What this does:<\/b> We are securely passing your password into <code data-path-to-node=\"22\" data-index-in-node=\"59\">sudo -S<\/code> so the command can run with root privileges without prompting you on a broken screen. It forcefully removes the corrupted <code data-path-to-node=\"22\" data-index-in-node=\"189\">\/dev\/null<\/code> file and uses <code data-path-to-node=\"22\" data-index-in-node=\"213\">mknod<\/code> to recreate it as a character device file (<code data-path-to-node=\"22\" data-index-in-node=\"262\">c 1 3<\/code>) with open read\/write permissions (<code data-path-to-node=\"22\" data-index-in-node=\"303\">0666<\/code>).<\/p>\n<h3 data-path-to-node=\"23\"><span class=\"ez-toc-section\" id=\"Step_2_Fix_devptmx_and_Mount_the_Terminal\"><\/span>Step 2: Fix \/dev\/ptmx and Mount the Terminal<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p data-path-to-node=\"24\">Once the scripts are quiet, we need to fix the terminal allocator so you can actually type again. Run this second command from your local machine:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ssh user@YOUR_SERVER_IP \"echo 'YOUR_PASSWORD' | sudo -S su -c 'rm -f \/dev\/ptmx &amp;&amp; mknod -m 666 \/dev\/ptmx c 5 2 &amp;&amp; chmod 666 \/dev\/ptmx &amp;&amp; mount -t devpts devpts \/dev\/pts'\"<\/pre>\n<p data-path-to-node=\"26\"><b data-path-to-node=\"26\" data-index-in-node=\"0\">What this does:<\/b> Similar to the first step, this removes any broken <code data-path-to-node=\"26\" data-index-in-node=\"67\">\/dev\/ptmx<\/code> file and rebuilds it (<code data-path-to-node=\"26\" data-index-in-node=\"99\">c 5 2<\/code>). We enforce the <code data-path-to-node=\"26\" data-index-in-node=\"122\">666<\/code> permissions to ensure all users can request a terminal. Finally, <code data-path-to-node=\"26\" data-index-in-node=\"191\">mount -t devpts<\/code> mounts the pseudo-terminal filesystem, which is the final piece required to render your command line properly.<\/p>\n<h1 data-path-to-node=\"27\"><span class=\"ez-toc-section\" id=\"Clean_Up_and_Security_Best_Practices\"><\/span>Clean Up and Security Best Practices<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p data-path-to-node=\"28\">Wait a few seconds for the commands to finish executing. Once you are returned to your local command prompt, you can open your SSH client and log in normally. Your server should now be fully responsive.<\/p>\n<p data-path-to-node=\"29\"><b data-path-to-node=\"29\" data-index-in-node=\"0\">Important Post-Fix Security Steps:<\/b><\/p>\n<ol start=\"1\" data-path-to-node=\"30\">\n<li>\n<p data-path-to-node=\"30,0,0\"><b data-path-to-node=\"30,0,0\" data-index-in-node=\"0\">Clear Your Local History:<\/b> Because you passed your password in plain text within the command line, it is now saved in your local terminal history. Clear your local bash history (<code data-path-to-node=\"30,0,0\" data-index-in-node=\"177\">history -c<\/code>) or immediately change your server&#8217;s admin password.<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"30,1,0\"><b data-path-to-node=\"30,1,0\" data-index-in-node=\"0\">Harden Your SSH Configuration:<\/b> These types of system file corruptions can sometimes be the aftermath of automated attacks or messy scripts. Check your server logs for brute-force attempts. If you haven&#8217;t already, change your default SSH port from <code data-path-to-node=\"30,1,0\" data-index-in-node=\"247\">22<\/code> to a custom port, disable password authentication in favor of SSH Keys, and install <b data-path-to-node=\"30,1,0\" data-index-in-node=\"334\">Fail2Ban<\/b> to block malicious IP addresses automatically.<\/p>\n<\/li>\n<\/ol>\n<p data-path-to-node=\"7\">Running into the &#8216;Server refused to allocate pty&#8217; or &#8216;\/dev\/null permission denied&#8217; error can feel like a sysadmin&#8217;s nightmare, especially when you are entirely locked out of the shell. However, by bypassing the interactive terminal and pushing those two remote SSH commands, you can easily restore your device nodes and regain full access without needing to reinstall your OS.<\/p>\n<p data-path-to-node=\"8\">Did this guide help save your server from a forced reboot? Or do you have another trick to handle frozen SSH sessions? Let me know in the comments below, and don&#8217;t forget to bookmark this page for your future system administration needs!<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>Managing a VPS or dedicated server is usually smooth sailing\u2014until you are suddenly locked out&#8230;<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":866,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[682,684,686,681,685,683],"newstopic":[687],"class_list":["post-865","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorial","tag-dev-null-permission-denied","tag-fix-dev-ptmx","tag-linux-pseudo-terminal-error","tag-pty-allocation-request-failed","tag-ssh-hang-after-login","tag-ssh-terminal-frozen","newstopic-fix-server-refused-to-allocate-pty"],"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/arizu.id\/blog\/wp-json\/wp\/v2\/posts\/865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arizu.id\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arizu.id\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arizu.id\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arizu.id\/blog\/wp-json\/wp\/v2\/comments?post=865"}],"version-history":[{"count":3,"href":"https:\/\/arizu.id\/blog\/wp-json\/wp\/v2\/posts\/865\/revisions"}],"predecessor-version":[{"id":869,"href":"https:\/\/arizu.id\/blog\/wp-json\/wp\/v2\/posts\/865\/revisions\/869"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arizu.id\/blog\/wp-json\/wp\/v2\/media\/866"}],"wp:attachment":[{"href":"https:\/\/arizu.id\/blog\/wp-json\/wp\/v2\/media?parent=865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arizu.id\/blog\/wp-json\/wp\/v2\/categories?post=865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arizu.id\/blog\/wp-json\/wp\/v2\/tags?post=865"},{"taxonomy":"newstopic","embeddable":true,"href":"https:\/\/arizu.id\/blog\/wp-json\/wp\/v2\/newstopic?post=865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}