Synapict and gparted – cannot open display

When I try to open synaptic or gparted in Ubuntu 17.10, I run into problems. The error looks like this

No protocol specified
Unable to init server: Verbindung ist gescheitert: Verbindungsaufbau abgelehnt

(synaptic:8832): Gtk-WARNING **: cannot open display: :0

To solve the problem, simple use the following command

xhost +SI:localuser:root

Thanks to https://askubuntu.com/questions/961967/why-dont-gksu-gksudo-or-launching-a-graphical-application-with-sudo-work-with-w