This usually only occurs when you are trying to run an X application from either a console or a terminal under an X session you didn't start as that user. Thoroughly confused?
If you logged in as root and typed:
And then, opened up a terminal and typed:
su - username
And followed with:
You'd likely get that error as your user doesn't have permissions to run X applications in root's X session (same goes in reverse and parallel, nobody except the user who started the X session can execute X apps in it).
However, there is a workaround:
This should allow anyone on your local machine to run X apps in any X session, type that in before you 'startx' and it should render this ability available.
Another option is to startx as the user you are going to use to launch the app. If you don't want to close down the current X session:
CTRL ALT F2
to another console, login as the user, and type:
startx -- :1
This'll start an X session on tty8 and the old session'll be on tty7, to switch you type:
CTRL ALT F7/F8
This display is now known from the Xserver as 0:1