Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Possible Duplicate:
Open a window on a remote X display (why “Cannot open display”)?

I have a script that when run independently works that needs X11 Display variables to be set. When I invoke this script using a background daemon job, I get the following error.
Xlib: connection to "localhost.localdomain:0.0" refused by server
Xlib: No protocol specified
Please help me identifying the possible mistake that I have in this.
Commands given below which is inside the script.
export DISPLAY=hostname:0.0
java ScreenCapture
If the same script is invoked by a background daemon running as a service, I get the error.

share|improve this question

marked as duplicate by Gilles, Renan, jasonwryan, warl0ck, Mat Oct 7 '12 at 6:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

I'm just guessing here, but the background daemon might be running as different user, which does not have permission to access the display.

You can use xhost to control user access:

The xhost program is used to add and delete host names or user names to the list allowed to make connections to the X server.

You can test if this is the problem by running:

xhost +

from a terminal window, which will allow any user to access the display.

xhost +(insert username here)

will allow access for a specific user.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.