Fix X11 Forwarding Requested but DISPLAY Not Set

The message debug1: X11 forwarding requested but DISPLAY not set means SSH on your computer has no local X display to use. Start your local X server, then reconnect from a terminal with a valid DISPLAY.

On a Mac, launch XQuartz, then start a new terminal; install XQuartz first if it's missing. If forwarding still fails once your local display works, the next checks are on the remote host.

1. Check DISPLAY before connecting

Run this in a terminal on the computer where you type ssh, before opening the remote connection:

printenv DISPLAY

No output means DISPLAY isn't set in that terminal. This environment variable tells X11 programs where to put their windows. SSH needs this setting to show a remote program's window on your computer.

Drawing of a local Terminal window with printenv DISPLAY and the SSH reconnect command

A remote shell is the wrong place for this first check. Type exit to leave an existing SSH session, then run the command locally. Otherwise, an empty value on the remote machine can send you toward server changes too early.

For command-line access without graphical windows, reconnect using ssh -x user@host. The lowercase -x disables X11 forwarding on this connection, overriding a saved forwarding request.

Replace user@host with your actual login and server. A missing local display is harmless for command-line work; it matters when the goal is to bring a graphical application's window back to this computer.

2. Start XQuartz on a Mac, then use a fresh session

macOS doesn't include an X11 server. Apple's X11 for Mac page directs Mac users to XQuartz, which supplies the local server and client libraries.

Install the current XQuartz package from its official site if it isn't installed. Follow the installer's session or restart instructions, then open XQuartz from Applications > Utilities.

Drawing of the XQuartz Quick Download section with the package download marked

Open a new terminal and run printenv DISPLAY again. A normal XQuartz value can contain a long launchd socket path ending in org.xquartz:0. The path varies between sessions; don't copy one from another computer.

If the ordinary terminal still has an empty value, try the xterm window launched by XQuartz. That gives you a terminal associated with the X server. Run the same check there before reconnecting.

One owner fixed this after installing XQuartz and restarting their Mac; setting a display value alone hadn't been enough. That result fits the session problem: a terminal you left open can keep the settings it had before installation.

Reconnect using ssh -X user@host once the local value is present. A successful forwarding setup gets past the original debug message. Test the graphical application only after you've connected.

3. Remove an old DISPLAY override

A manually saved DISPLAY=:0 can point at the wrong destination on a modern Mac. Don't add it to your shell profile just because another system uses that value. XQuartz normally gets its own address from launchd, the macOS service manager.

Check your shell startup files for an old assignment. This read-only command searches common locations in your home folder:

grep -n DISPLAY ~/.zshrc ~/.zprofile ~/.bashrc ~/.bash_profile ~/.profile 2>/dev/null

Look for a line that assigns or exports DISPLAY. Back up that startup file, then remove or comment out just the old DISPLAY assignment. Open a fresh shell afterward and check the value again.

Don't remove every line mentioning X11. A comment or an unrelated command isn't necessarily an override. If the assignment comes from a managed work setup, ask its administrator before changing those settings.

For help reaching the right shell, opening Terminal in a Mac folder covers the local app. If a separate permissions error prevents access to a file, use the Terminal Operation not permitted checks.

4. Use the local X session on Linux or Windows

On Linux, run SSH from a terminal inside the graphical desktop session that can open an X application locally. A text console or a shell reached through another remote login may not have a local X display available.

Don't overwrite a working Linux DISPLAY just to make it resemble a Mac example. The important result is a valid destination for the local X server, not one particular spelling of the variable.

On Windows, an SSH client and an X server are separate pieces. Starting Windows Terminal or installing the OpenSSH client doesn't by itself create an X display. Use the connection instructions for the X server you've installed.

Windows Subsystem for Linux (WSL) has its own shell settings. Check DISPLAY where you run SSH and confirm that a local graphical X application opens there. Don't assume Windows and WSL shells share the same value.

If a simple local X application won't open, repair that local setup first. Editing the remote host can't supply the missing local server. Once local X applications work, start a new SSH connection with forwarding enabled.

5. Check the remote host only after the local display works

Connect with extra logging when the local value is present but forwarding still fails:

ssh -vvv -X user@host

Inside that new connection, run printenv DISPLAY again. SSH normally assigns a remote forwarding display, often in a form such as localhost:10.0. The number is assigned by the connection and can differ.

Leave that remote value alone. OpenSSH's manual says not to set DISPLAY manually for forwarded sessions. Pointing it at your laptop's network address bypasses the display SSH created for the encrypted connection.

If it stays empty, have the administrator review the active X11Forwarding settings and xauth, the X11 authorization tool.

Send the forwarding-related lines from the verbose connection output, removing hostnames and private account details.

I'd keep -X while checking this. Switching to trusted forwarding with -Y grants remote X clients more access and doesn't create a missing local DISPLAY. Use it only when the remote application needs it and the host is trusted.

If other accounts work, check your remote shell's startup files for a DISPLAY override. Send local X failures to XQuartz support. If forwarding fails only after local X works, send those connection details to the server administrator.

The Short Version

Check DISPLAY on the SSH client first. On a Mac, start XQuartz, refresh the login session when needed and reconnect with ssh -X. Let SSH set the remote DISPLAY instead of inventing an address.

Checked December 1, 2026.

If you have any business, I can build it online

Hi, I’m Hamza. I’ve been building websites and online shops for business owners since 2019, and I also built this site you’re reading.

Tell me what business you have or what you’re working on. I’ll look into how much it can grow online, and then we talk. You don’t have to buy anything or hire me first.

Chat with me on my site and I’ll show you proof of businesses I’ve helped and how they’ve grown.

Written by Isaac Smith

Isaac Smith is the founder and editor of PC Glance, a website that covers computers, laptops, and technology. He is a tech enthusiast and a computer geek who loves to share his insights and help his readers make smart choices when buying tech gadgets or laptops. He is always curious and updated about the latest tech trends.

More from Isaac Smith

Leave a Comment