Terminal Freezes When Running Top or Htop? Fix It Here
Your terminal locks up when running top/htop? Usually a terminal emulator bug or a runaway process. Here's what actually works.
Cause #1: Terminal Emulator Bug with ncurses Rendering
This is the most common cause I see. You're running top or htop in something like GNOME Terminal, Kitty, or Alacritty, and suddenly the whole terminal freezes—no input, no cursor movement, just a frozen screen. The culprit? A buggy ncurses rendering loop that locks up the terminal emulator's input thread.
I had a client last month whose whole dev team couldn't run htop without their terminals freezing. They were all on GNOME Terminal 3.44 with a specific font cache corruption. The fix? Switch to a different terminal emulator temporarily. But you don't always want to do that.
Fix: Kill the terminal with pkill and switch to a TTY
When it freezes, don't force reboot. Hit Ctrl+Alt+F2 (or F3–F6) to switch to a virtual console TTY. Then run:
ps aux | grep -E 'top|htop|gnome-terminal' | grep -v grep
kill -9 [PID of top/htop]
After that, Ctrl+Alt+F1 to go back to your graphical session. The terminal should recover.
Long-term fix: Update your terminal emulator. Or, if you're on an older distro like Ubuntu 20.04, try using tmux inside the terminal—it often sidesteps the ncurses-render bug. I've seen Kitty 0.26 fix this entirely—users on Kitty 0.22 had the freeze, and upgrading sorted it.
Also, check your font cache:
fc-cache -f -v
Corrupted font caches trigger ncurses to misrender characters, causing the terminal to hang. No joke.
Cause #2: A Runaway Process Flooding stdout Sending SIGSTOP to All Processes
This one is sneaky. You run htop, and it shows a process that's gone wild—spamming output to stdout, eating 99% CPU. That process might trigger SIGSTOP from the kernel's OOM handler or from htop itself if you accidentally pressed Ctrl+Z while in its UI. Yes, Ctrl+Z in htop suspends htop, but it can also suspend child processes. If you had multiple shells open, the whole group might be stopped.
I once had a server where a Python script went into an infinite loop writing to /dev/pts/0. Top froze the entire SSH session because the terminal couldn't handle the flood of output. The real fix was killing that script.
Fix: Check for stopped jobs and kill them
From a TTY (use Ctrl+Alt+F2 if your GUI terminal is frozen), run:
jobs -l
kill -9 %1
Or find the stopped process:
ps aux | grep 'T' # T status = stopped
kill -9 [PID]
If htop itself is stopped (you see it with status T in ps), just kill it. Then restart it cleanly: htop.
Prevention: Don't hit Ctrl+Z inside htop. Use q to quit. If you need to background a process, use screen or tmux.
Cause #3: Terminal Scrollback Buffer Overflow (Memory Exhaustion)
This is rarer but brutal. If your terminal emulator has a huge scrollback buffer (like 10,000+ lines) and you're running htop with a ton of processes, the terminal's memory usage can spike. The result? The terminal process starts swapping, the GUI becomes unresponsive, and your entire desktop might freeze.
I saw this on a client's system with 8GB RAM and 300+ processes. Running htop in GNOME Terminal with unlimited scrollback caused the memory to hit 95%. The terminal froze solid.
Fix: Reduce scrollback and use a lightweight terminal
First, from a TTY, kill the terminal:
pkill -9 gnome-terminal
Then, before reopening, set scrollback to something sane. In GNOME Terminal: Edit → Preferences → Profile → Scrolling → Limit scrollback to 1000 lines. In Kitty: set scrollback_lines 1000 in kitty.conf. In Alacritty: window.scrollback.lines: 1000 in alacritty.yml.
If you're on a low-memory system, use st (simple terminal) or xterm—they don't have large scrollback buffers and won't choke.
Quick test: Before running htop, check your free memory:
free -h
If you're under 2GB free, switch to a lighter terminal or run htop inside screen.
Quick-Reference Summary Table
| Cause | Symptom | Immediate Fix | Long-Term Fix |
|---|---|---|---|
| ncurses rendering bug in terminal emulator | Terminal freezes after a few seconds of top/htop | Switch to TTY, kill top/htop with kill -9 | Update terminal emulator or switch to Kitty/Alacritty |
| Runaway process flooding stdout or SIGSTOP | Terminal freezes, but TTY is fine; process shows status T | Find stopped process with ps aux | grep T, kill -9 it | Don't press Ctrl+Z in htop; use q to quit |
| Scrollback buffer memory exhaustion | Whole desktop becomes sluggish, terminal uses 90%+ RAM | pkill -9 terminal emulator from TTY | Limit scrollback to 1000 lines or use a lightweight terminal |
One last piece of advice: if this keeps happening, try using btm (Bottom) instead of htop. It's a Rust-based process viewer that's less prone to ncurses issues. But that's a different article.
Was this solution helpful?