Don’t use “xhost +”, it allows anyone and everyone to connect to your X server!
You can either set the XAUTHORITY environment variable for the root shell to point at your user’s authority file, or do “xhost +si:localuser:root” to allow root to connect to the X server without the authority file.
If you’re using nvidia-settings to edit xorg.conf, I would recommend running it as a normal user, saving the new xorg.conf somewhere your user can write to, and then switching to root only to copy it to /etc/X11.