I had the same problem. Solved now.
I was using TMUX, it's a screen manager for bash on Linux. (similar to `screen`).
When I ran bitcoin GUI from within TMUX I would get that error. But when I ran it from a fresh new terminal, it worked.
So, you should make sure the terminal has access to X11. Running `xclock` is a good way to test that as others mentioned.