What you're seeing
You're logged in over SSH, you launch a graphical program, and it refuses:
$ xclock
Error: Can't open display:Variants of the same failure:
xclock: cannot connect to X servercannot open display: localhost:10.0(forwarding started, then broke)Gtk-WARNING **: cannot open display:(any GTK app: gedit, firefox, virt-manager)qt.qpa.xcb: could not connect to display(Qt apps)
The SSH login itself succeeded. This error is about the extra channel that carries graphics back to your machine, and that channel has to be set up on both ends.
What's causing this error
A GUI program on the server doesn't draw its own window. It sends drawing commands to an X server, and over SSH that X server is on your machine. The chain looks like this: app on the server reads DISPLAY, sshd feeds the traffic back through the tunnel, PuTTY hands it to an X server running on Windows. The error means a link is missing:
- No X server on Windows. Windows can't display X11 graphics natively. PuTTY forwards the traffic but has nowhere to deliver it. You need VcXsrv or Xming running first. This is the cause people miss, because nothing tells you the piece is missing.
- X11 forwarding not enabled in PuTTY. It's off by default, and it only takes effect on sessions opened after you enable it.
- The server can't do its part.
xauthisn't installed, orsshd_confighasX11Forwarding no. Forwarding then fails silently: no error at login,DISPLAYjust never gets set. DISPLAYis empty or wrong in your shell, which is usually a symptom of 1 to 3 rather than a cause of its own.
How to fix it
Work through these in order; each step depends on the one before it.
Step 1: Install and start an X server on Windows
Install VcXsrv (actively maintained) or Xming, and start it before you connect. For VcXsrv, run XLaunch and accept the defaults: "Multiple windows", display number 0. It sits in the system tray doing nothing visible, which is normal.
If you searched for "xming download for putty": Xming is a separate program, not a PuTTY component or plugin. You get PuTTY from the PuTTY download page and the X server from its own project page, and both must be running.
Step 2: Enable X11 forwarding in PuTTY
In the PuTTY configuration window, before connecting:
- Go to Connection > SSH > X11
- Check Enable X11 forwarding
- Set X display location to
localhost:0 - Go back to Session, select your saved session, and click Save so it sticks
Then open the connection. Enabling this mid-session does nothing; it has to be set when the session starts.
Step 3: Fix the server side
On the server, xauth must be installed:
sudo apt install xauth # Debian/Ubuntu
sudo dnf install xorg-x11-xauth # RHEL/FedoraAnd sshd must allow forwarding:
sudo grep -i x11forwarding /etc/ssh/sshd_configYou want X11Forwarding yes. If you change it, restart sshd:
sudo systemctl restart ssh # Debian/Ubuntu
sudo systemctl restart sshd # RHEL/CentOS/FedoraStep 4: Reconnect and verify
Close the session and open a new one (this matters; the forwarding handshake happens at login). Then:
echo $DISPLAYYou should see something like localhost:10.0. If it prints that, test with a small X app:
sudo apt install x11-apps
xclockA clock window pops up on your Windows desktop and you're done. If DISPLAY is still empty, open PuTTY's Event Log (right-click the title bar > Event Log) and look for X11-related refusals; they name which end declined.
On a Mac
There's no official PuTTY here, and you don't need one. Install XQuartz, log out and back in once, then use the built-in client with forwarding enabled:
ssh -X [email protected]The cannot open display logic is the same: XQuartz is the X server, and it must be installed before the message goes away.
Common edge cases
| Situation | What's actually wrong |
|---|---|
Works as your user, fails after sudo | sudo strips DISPLAY and the xauth cookie. Run sudo -E env DISPLAY=$DISPLAY XAUTHORITY=$HOME/.Xauthority the-app, or copy the cookie once with `xauth extract - $DISPLAY |
DISPLAY looks right but connection still refused | Stale X11 cookie after a hostname change. rm ~/.Xauthority on the server, then reconnect |
| App insists on Wayland on a modern server | X11 forwarding only carries X11. Most toolkits fall back if you force it: GDK_BACKEND=x11 the-app or QT_QPA_PLATFORM=xcb the-app |
| On Windows 11 with WSL available | WSLg runs Linux GUI apps with zero X server setup. ssh -X from a WSL terminal replaces the PuTTY + VcXsrv pairing entirely |
putty: cannot open display when launching PuTTY itself on Linux | Different problem: PuTTY is a GTK app and you started it with no graphical session (a TTY, or over plain SSH). Run it inside a desktop session |
| Forwarding works but apps are painfully slow | X11 over SSH is chatty on high-latency links. Turn on Connection > SSH > Enable compression, or use the app's own remote mode instead |