Home > Software > Resolving the “Missing X Server or $DISPLAY” Issue in Unix/Linux Environments

Resolving the “Missing X Server or $DISPLAY” Issue in Unix/Linux Environments

Anastasios Antoniadis

Learn how to fix the “Missing X Server or $DISPLAY” error in Unix/Linux environments. This guide covers understanding the X Server, configuring the $DISPLAY variable, using SSH with X forwarding, and troubleshooting tips to seamlessly run graphical applications locally or remotely.


Encountering the “Missing X Server or $DISPLAY” error can be a roadblock for users attempting to run graphical applications from a terminal or through a remote connection in Unix and Linux. This error indicates that the application cannot connect to the X Server, which is a crucial component for managing graphical displays on Unix-like systems. It’s important to understand the root causes of this issue and know how to resolve it for seamless operation in these environments. This article will delve into the causes of the “Missing X Server or $DISPLAY” error, explore its implications, and provide detailed solutions to help you get your graphical applications running smoothly again.

Understanding the X Server and $DISPLAY Variable

Before tackling the error, it’s important to understand two fundamental concepts in Unix/Linux graphical environments: the X Server and the $DISPLAY environment variable.

X Server

The X Server is the backbone of the Unix/Linux graphical interface, managing the display, input devices, and graphical rendering. It acts as an intermediary between graphical applications (X clients) and the hardware, displaying the graphical output of applications and relaying user input back to them.

$DISPLAY Environment Variable

The $DISPLAY environment variable tells graphical applications how to connect to the X Server. It typically includes the X Server’s hostname (or IP address) and a screen number. For example, :0 indicates the first screen of the local X Server, while hostname:0 would refer to the first screen of an X Server running on hostname.

Causes of the “Missing X Server or $DISPLAY” Error

This error can occur in various situations, including:

  • Running Graphical Applications Remotely: When connecting to a Unix/Linux system via SSH and trying to launch a graphical application without proper X Server forwarding.
  • Incorrect $DISPLAY Settings: The $DISPLAY variable is not set correctly, or at all, preventing applications from knowing where to send their graphical output.
  • X Server Not Installed or Running: On headless servers or minimal installations, the X Server might not be installed, or it’s not running.

Resolving the Error

Ensuring the X Server is Installed and Running

First, make sure that an X Server is installed on your system. You might need to install it manually on headless servers or minimal installations.

For Ubuntu/Debian-based systems, you can install a lightweight X Server with:

sudo apt-get install xorg openbox

Ensure that the X Server is running. If you’re using a desktop environment, it’s likely already up and running. On a server or minimal installation, you might need to start it manually or configure it to start on boot.

Configuring $DISPLAY Correctly

Ensure your $DISPLAY variable is set correctly. For local applications, it’s often set automatically, but for remote connections, you may need to set it manually:

export DISPLAY=:0

This command sets the $DISPLAY variable to use the first screen of the local X Server. Adjust the screen number as necessary.

Using SSH with X Forwarding

When running graphical applications over SSH, use X forwarding to tunnel the graphical output back to your local machine’s X Server. This can be done with the -X or -Y options:

ssh -X username@hostname

Ensure your SSH client supports X forwarding and that the SSH server on the remote machine is configured to allow it. On the server, the sshd_config file should have the X11Forwarding yes option set.

Troubleshooting Tips

  • Verify X Server Access: Use the xhost command to manage access to your X Server. Running xhost + will temporarily allow all users to connect to your X Server, which can help determine if access control is the issue. Be cautious, as this can pose a security risk.
  • Check for Firewalls: Ensure that no firewalls are blocking the connection to the X Server, especially if connecting remotely.
  • Consult Logs: X Server logs, often found in /var/log/Xorg.0.log, can provide clues to connection issues or errors.


The “Missing X Server or $DISPLAY” error can be a frustrating hurdle when working with graphical applications in Unix/Linux environments. However, by understanding the role of the X Server and the $DISPLAY variable, ensuring correct configuration, and utilizing tools like SSH with X forwarding, you can overcome this challenge. Remember to verify your system’s setup, check for common pitfalls, and employ best practices for secure and efficient operation. With these strategies in hand, you’ll be well-equipped to run graphical applications smoothly, whether locally or over remote connections.

Anastasios Antoniadis
Follow me
0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x