How I fixed SSH X11 forwarding sudo: Unable to init server: Could not connect: Connection refused

Problem:

While I was trying to run sudo gparted, the following error occured:

X11 connection rejected because of wrong authentication.
Unable to init server: Could not connect: Connection refused

(gpartedbin:29293): Gtk-WARNING **: 01:55:02.070: cannot open display: localhost:10.0

Solution

For me, the solution was to copy the .Xauthority file from the user uli I logged in as to root:

sudo cp ~$USER/.Xauthority /root

as this was required for the X11 program running as root to properly login to my local X11 server.