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

How to Fix: Opening FireFox from CLI causes X error "cannot open display: 0"

Error opening Firefox from CLI in Linux due to display issue.

Quick Answer: Try setting DISPLAY to ':0' or use a tool like 'xdg-screensaver' to determine the correct display value.

When trying to open Firefox from the Linux CLI, users encounter an error that prevents the browser from launching. The error message 'cannot open display: :0' is displayed, and it can be frustrating for those who rely on this application for their daily tasks.

This issue affects users who have set up their system to run in a way that doesn't allow the default display to work properly. It's essential to identify the root cause of this problem and implement a solution to resolve it.

🔍 Why This Happens

  • The primary reason for this error is that the DISPLAY environment variable is not set correctly. In Linux, the DISPLAY environment variable specifies the X server to use for graphical applications. If it's not set or set incorrectly, it can cause issues like this.
  • Another possible reason could be a conflict with other graphical applications running on the system, which might be using the same display.

🚀 How to Resolve This Issue

Setting the DISPLAY environment variable manually

  1. Step 1: To fix this issue, you need to set the DISPLAY environment variable manually. You can do this by adding the following command before running Firefox from the CLI: export DISPLAY=:0 (or :1, or :0.0, depending on your system's configuration). This sets the display to use the default X server.
  2. Step 2: Alternatively, if you're using a Linux distribution that uses the Wayland display manager, you might need to set the DISPLAY variable differently. You can try setting it to ':0' (without the dot) and then log out and log back in to see if it resolves the issue.

Checking the X server configuration

  1. Step 1: If manual setting of the DISPLAY variable doesn't work, you might need to check your X server configuration. You can do this by running the following command: nvidia-smi (if you have a NVIDIA GPU) or glxgears (for other GPUs). This will show you the current display settings.
  2. Step 2: If you find that there's an issue with your X server configuration, you might need to restart it or reinstall the X server package.

💡 Conclusion

To summarize, setting the DISPLAY environment variable manually is usually the primary fix for this error. However, if manual setting doesn't work, checking the X server configuration and making any necessary adjustments can also resolve the issue.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions