Software⏱️ 3 min read📅 2026-06-15

How to Fix: Xterm giving error that DISPLAY is not set

Xterm error when DISPLAY is not set on Ubuntu 13.04, resolve using ssh -Y or X11 forwarding.

Quick Answer: Use ssh -Y to enable X11 forwarding or specify the DISPLAY environment variable.

The 'DISPLAY is not set' error in Xterm can be frustrating, especially when working remotely using SSH. This issue affects users who connect to servers using ssh -X and attempt to run graphical applications like Xterm.

This problem occurs because the DISPLAY environment variable is not properly configured for remote connections. As a result, Xterm cannot establish a connection to the local display server, leading to the 'Can't open display' error.

🔍 Why This Happens

  • The primary reason for this error is that the DISPLAY environment variable is not set when using ssh -X. This is because the DISPLAY variable is specific to the local machine and is not forwarded by SSH.
  • Another potential cause is that the X server on the remote machine is not running or is not configured correctly.

🛠️ Step-by-Step Verified Fixes

Configuring DISPLAY Environment Variable

  1. Step 1: To resolve this issue, you need to set the DISPLAY environment variable manually. You can do this by adding the following line to your ssh command: -Y (or --force-interactive-mode). This will force SSH to open a pseudo-TTY and allow you to forward the DISPLAY variable.
  2. Step 2: Alternatively, you can also use the -X option with the DISPLAY variable set explicitly, like this: ssh -X :0 user@server. Replace 0 with your local display number.
  3. Step 3: If you are using a recent version of Ubuntu, you may need to install the xauth package and configure it manually to forward the DISPLAY variable.

Configuring X Server on Remote Machine

  1. Step 1: Another approach is to configure the X server on the remote machine to allow forwarding of the DISPLAY variable. You can do this by adding the following lines to your /etc/X11/xinitrc file: Export DISPLAY, and Exec startx -s 'DISPLAY' (replace 'DISPLAY' with your local display number).
  2. Step 2: Alternatively, you can also use a tool like xauth to configure the forwarding of the DISPLAY variable. You can do this by running the command xauth -f :0 add . You will need to replace 0 with your local display number.

✨ Wrapping Up

By setting the DISPLAY environment variable manually or configuring the X server on the remote machine, you should be able to resolve the 'DISPLAY is not set' error in Xterm and successfully connect to your graphical applications.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions