OES2

Had this error when trying to run visual app as root when logged to the server as a user

The working solution was:

Run visudo

Add

env_keep+="DISPLAY XAUTHORITY"

to the Defaults line so it may look like:

Defaults !lecture,tty_tickets,!fqdn,env_keep+="DISPLAY XAUTHORITY"

Then sudo and gksudo won't mess up with 'Gtk-WARNING **: cannot open display:'

from here:
Gtk-WARNING **: cannot open display: [Archive] - Ubuntu Forums

Might help somebody else

Seb