givm Xlib connection to refused by server Xlib No protocol spectified

while trying gvim command from the root user it will open that graphical with vim editor,But when we try non-root user I can't open the gvim editor.
#gvim filename.txt
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
E233: cannot open displayXlib: connection to ":0.0" refused by server
Xlib: No protocol specified
PROBLEM
user try gvim command it will try to access X (Graphical) server.But That connection is refused by server
SOLUTION
Add the standard user ( non root user) to the xhost server
# xhost
access control enabled, only authorized clients can connect
SI:localuser:root
Default the gvim editor is enable only for the root user. To enable the non root user.
standard user. we have to run the following command.
xhost +local:username
#xhost +local:user2
Then try it gvim graphical vim editor it will open for the standard user.
Error:Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
E233: cannot open displayXlib: connection to ":0.0" refused by server
Xlib: No protocol specified

Related post