Error "Can't open display: localhost:x.y" When Running xclock on Xming
The Problem
Unable to do Display Setting for Xming. You get the error below while trying to run Xclock on server for non-root user , e.g. ‘oracle’:
$ xclock
Xlib: connection to "localhost:10.0" refused by server
Xlib: PuTTY X11 proxy: MIT-MAGIC-COOKIE-1 data did not match
Error: Can't open display: localhost:10.0
$
The Solution
Incorrect authorization information configuration was present on the X server. Follow the steps outlined below to resolve the issue:
1. Login as the root user
2. Type ‘xauth list’ to get authorization entries:
# xauth list
12-322-11-11/unix:10 MIT-MAGIC-COOKIE-1 cf4967d5a6c0e6d5f33285a3343dfdce
3. switch to the user:
# su - oracle
4. Add entire output using “xauth add” command:
$ xauth add "12-322-11-11/unix:10 MIT-MAGIC-COOKIE-1 cf4967d5a6c0e6d5f33285a3343dfdce"
5. start xclock again
$ xclock