You're trying to run it using from a user X session, yeah?
You need to do, as user ($):
That enables all users to access the current X session, you can do "xhost localhost" instead if you're concerned about security. I have this is one the bash RC files.
To switch access off again do "xhost -"