I'm trying to run Firefox GUI browser on headless CentOS server in order to perform some web testing.

I don't need to see the graphical output, because i use Selenium server API to control browser's input and inspect the output.

The setup was successfully tested on desktop Mac computer. It, however, fails to run on my headless VPS CentOS server with following message "Error: no display specified." (Which makes sense, since it's just a server sitting on a rack someplace.)

How can I get Firefox to run without a display, so Selenium will be able to interact with it? Or - more broadly - how do people run GUI-only applications on a Linux server when there is no display?

I've noticed that Firefox has this command line option:

X11 options
  --display=DISPLAY  X display to use

Unfortunately I don't know anything about X11 or displays under CentOS so I don't know what to specify on the command line, or if this would help.

  • 5
    I find it very strange that a question that has been starred 13 times is closed as "too localized". Jan 20, 2016 at 2:18
  • 3
    Exactly, I'm having similar issue and both the question and the answer were beneficial to me. It definetly should be reopened in case someone finds another solution.
    – Marek Rost
    Aug 6, 2016 at 12:07

1 Answer 1


Use Xvfb. It gives you an X server that doesn't require connection to a physical display.

(So, on CentOS, you'd do something like "yum install xorg-x11-server-Xvfb".)

You can then start it up on display ":1" with the command "/path/on/which/installed/Xvfb :1 -screen 0 1024x768x24 &". This will create a screen with resolution 1027x768 and depth 24. Use of "&" will make the command execute in the background.

Before launching Firefox, you need to make the display accessible, which is done using the Export command - ie. "export DISPLAY=:1", pointing to whatever host is appropriate.

  • Wow! Thanks! That works-- though I'm getting TONS of weird error messages from the display. I'll post a new question about those. Bottom line, despite the messages, it's working and returning the data I need. Thank you so much, this is just the help I needed.
    – Eric
    Feb 26, 2012 at 8:34
  • By the way-- how can I "shut down" the Xvfb display when I'm done with everything?
    – Eric
    Feb 26, 2012 at 8:35
  • You should be able to just kill the process. If you want to get more sophisticated, you can look into setting up start/stop scripts (if the package doesn't already provide it; it might: look in /etc/init.d for any xvfb script).
    – cjc
    Feb 26, 2012 at 11:23
  • 2
    Got it, thanks. I've posted a follow-up question regarding the info/error messages I'm seeing, in case you are looking for more reputation points :-) serverfault.com/questions/363914/…
    – Eric
    Feb 26, 2012 at 19:38
  • This answer is correct but you MUST keep in mind that the export command MUST be set on the same terminal session as the terminal you gonna run your firefox
    – TuyenNTA
    Sep 13, 2018 at 17:26

Not the answer you're looking for? Browse other questions tagged .