Xlib : connection refused by server

You may get the below error while running xhost + on Linux environment.

Xlib : connection refused by server
The IP address of this Linux environment is
Sceen 1

If your X Server running on Windows is Xming, then the fix is to be done from Xming's side, ie, from the Windows operating system.

The Xming logs shows the below error :

AUDIT: Sun Feb 02 11:56:00 2014: 4324 G:\Program_Files_(x86)\Xming\Xming.exe: client 4 rejected from IP

Hence, the rejection happens from the client running on Linux with IP address

The fix is to find the file X0.hosts in the installation folder of Xming (This, to me is on folder G:\Program_Files_(x86)\Xming). Open this file. You will see the content of this file will be a single line of localhost

Add the IP address of the host (in my case, you want to connect to in the file X0.hosts


From the terminal, set the DISPLAY

export DISPLAY

Run xhost + again

$ xhost +
access control disabled, clients can connect from any host
xhost:  must be on local machine to enable or disable access control.
Sceen 2