htop "Error opening terminal: xterm-ghostty." Fix
Fix htop's "Error opening terminal: xterm-ghostty." over SSH to a Mac: set TERM=xterm-256color or copy the terminfo entry. Same fix for xterm-kitty.
TroubleshootingUpdated 5 min read
On this page
You SSH into another Mac from Ghostty (or kitty), type htop, and get this:
Error opening terminal: xterm-ghostty.With kitty the last word is xterm-kitty. The command doesn't crash, it just refuses to draw anything.
Why htop reports "Error opening terminal"
When you SSH in, your terminal passes its TERM value to the remote machine. Ghostty sends xterm-ghostty, and kitty sends xterm-kitty. htop is built on the ncurses library, which looks that name up in the remote machine's terminfo database. If there is no entry, ncurses can't set up the screen and htop exits.
macOS ships entries for common terminals such as xterm-256color. Terminals that define their own TERM name usually aren't in that list. On your local Mac the entry exists because the terminal installed it, so everything works there. The remote Mac has never seen it.
htop is probably only the first program you tried. Other full-screen programs on that machine (vim, less, top, tmux) can fail or misbehave the same way.
To confirm, run this inside the SSH session:
echo $TERMIf it prints xterm-ghostty or xterm-kitty, this page applies.
| Cause | Symptom | Fix |
|---|---|---|
| Remote has no terminfo for your terminal | Error opening terminal: <name>. | Fix 1, 2 or 3 below |
| Entry copied, but to a different user | Still fails after copying | Re-run the copy for the user you log in as |
sudo drops or changes TERM | Works as you, fails under sudo | sudo env TERM=xterm-256color htop |
Multiplexer sets its own TERM | Error names tmux or screen | Check echo $TERM inside the multiplexer |
Step-by-step fixes
Fix 1: Override TERM on the remote Mac
Use this when you just need htop working now.
In the SSH session, run:
bash TERM=xterm-256color htopTo keep it for the rest of the session, run this instead and then start htop normally:
bash export TERM=xterm-256color
The first form affects one command only. The second lasts until you log out. The trade-off is that programs on the remote side see a generic xterm, not your terminal's own definition, so some terminal-specific features won't be used.
Fix 2: Install the terminfo entry on the remote Mac
Use this when you connect to the same machine often.
Open a Ghostty window on your local Mac. The
xterm-ghosttydefinition has to be readable there.Run, replacing
user@remote-macwith your login:bash infocmp -x xterm-ghostty | ssh user@remote-mac -- tic -x -Open a new SSH session and run
htop.
The command reads the terminal definition locally and pipes it to tic on the remote machine, which compiles it into that user's ~/.terminfo folder. It needs no admin rights and doesn't touch system files. It also works while the remote machine doesn't understand your TERM, because tic doesn't draw to the screen.
To check the entry arrived, run this on the remote Mac:
infocmp xterm-ghosttyA printed definition means it worked.
Fix 3: Make SSH always announce a common TERM
Use this when you connect to many machines and don't want to prepare each one.
Add this line to your local
~/.zshrc:bash alias ssh='TERM=xterm-256color ssh'Open a new local tab.
Every ssh command now announces xterm-256color. To undo it, delete the line.
You can also change the terminal itself. Ghostty has a term setting in its config file, and kitty has a term option in kitty.conf. Setting either to xterm-256color makes the terminal announce that name everywhere, local sessions included. Check the Ghostty or kitty documentation first, because local programs then lose anything that depends on the terminal's own definition. Recent Ghostty versions also have shell-integration options for SSH; see Ghostty's documentation for your version.
kitty: "Error opening terminal: xterm-kitty."
The cause is identical, and so are the fixes. The kitty issue tracker has a report of this exact message on an Ubuntu remote. Pick one:
Use kitty's SSH helper. Run
kitty +kitten ssh user@hostinstead ofssh. kitty copies its terminfo to the remote machine for you.Copy the entry yourself, from inside kitty:
bash infocmp -x xterm-kitty | ssh user@host -- tic -x -On a Debian or Ubuntu remote, install the package that ships the entry with
sudo apt install kitty-terminfo. To undo it, runsudo apt remove kitty-terminfo.Override TERM as in Fix 1 or Fix 3.
Checklist before you try again
echo $TERMon the remote shows the name in the error message.- You ran the
infocmpcommand from inside the terminal that owns the entry (Ghostty or kitty). - You installed the entry for the same user you log in as on the remote Mac.
- You opened a new SSH session after installing it.
- If you use
sudo, you passedTERMexplicitly.
Other problems after the fix
infocmp -x xterm-ghostty says the terminal is unknown locally. You ran it in a different terminal app, such as Terminal. Run it from a Ghostty window.
tic fails on the remote Mac. Skip the copy and use Fix 1 or Fix 3.
htop works as you but fails under sudo. sudo may reset TERM or look in a different home folder. Pass it explicitly:
sudo env TERM=xterm-256color htopYou need a process list right now. ps doesn't draw to the screen, so it runs with any TERM. On the remote Mac:
ps -Ao pid,pcpu,pmem,comm -r | head -n 11This prints a header plus the 10 busiest processes by CPU. The CPU figure is an average over each process's lifetime, not a live reading, so treat it as a rough view.
If nothing works
Report it to the terminal's project (Ghostty or kitty) or to htop. Include the output of echo $TERM on both machines, the macOS version of the remote Mac, and the exact command you used to copy the terminfo entry.
htop fails over SSH with: Error opening terminal: xterm-ghostty.
Local: macOS <version>, Ghostty <version>, TERM=xterm-ghostty
Remote: macOS <version>, TERM=xterm-ghostty (before any override)
Tried: TERM=xterm-256color htop (result: ...)
Tried: infocmp -x xterm-ghostty | ssh user@host -- tic -x - (output: ...)
infocmp xterm-ghostty on the remote prints: ...Common questions
Does this only happen over SSH?
Mostly. Locally your terminal installs its own entry, so the name resolves. Over SSH the remote machine has to find the entry itself, and it can't unless you copy it there.
Is TERM=xterm-256color safe to use?
Yes. It's a standard entry that macOS includes, and htop works fully with it. You lose only features specific to Ghostty or kitty.
Will I have to repeat the copy for every remote Mac?
Yes, once per machine and per user account. The entry lives in that user's ~/.terminfo folder. If you manage many machines, Fix 3 avoids the per-machine step.
Do I need to restart anything after copying the entry?
No. Open a new SSH session and the remote shell picks it up. Existing sessions keep the state they started with.