_X11TransSocketINETConnect() can't get address for localhost

I connected a CentOS 5 box using PuTTY and ran emacs, but I got the following error.

------------------------------------------------------
$ emacs
_X11TransSocketINETConnect() can't get address for localhost:6011: Name or service not known
emacs: Cannot connect to X server localhost:11.0.
Check the DISPLAY environment variable or use `-d'.
Also use the `xhost' program to verify that it is set to permit
connections from your machine.
---------------------------------------------------

I use Xming as an X server on Windows XP. I checked the X11 option of PuTTY, the sshd setting, and the firewall setting. All the settings were okay. According to the error message, the problem is that the name of "localhost" is not resolved. I took a look at the /etc/hosts file and found the file was empty. So I added the following line to the file.

127.0.0.1 localhost.localdomain localhost

The problem is fixed. I don't know why the file is empty though...

9 comments:

Unknown said...

Wow! Your post gives me a exact solution! Now I can see X11 windows by using putty & Xming. Thank you.

Masa Murayama said...

You're welcome :)

Artur said...

Thank you BIG TIME!

Taylor Hamilton said...

...And thanks again in 2011.

retheesh said...

I have similar issues with DISPLAY

I am trying to run the java code which reads some JPEG files and print its width and height. However, I code enters its first line then the following error is displaying

I run the java with the following
===================================
-bash-3.2$ java -classpath .:jai_codec-1.1.3-alpha.jar:rt.jar:jai-core-1.1.3-alpha.jar:jai_linux-i586.jar TestFinal

This is the first line of the code which printed
==========================
Entering Static Block

the following error is displaying
=================================
(.:30839): Gtk-WARNING **: cannot open display:
-bash-3.2$
I tried with the following
================================
-bash-3.2$ echo $DISPLAY
:0.0
-bash-3.2$
-bash-3.2$

how could we resolve this

retheesh said...

you may send mail to 9.retheesh@gmail.com for the above discussion

Unknown said...

Thanks a lot. worked for me.

Anonymous said...

thanks

Aktar Alam said...

Thanks a lot...
You saved my day.
I was trying to set DISPLAY to :0.0 but still was not able to open any application which uses X windows.

Good Bye, Folks!

As you may have heard, Fujitsu has completely discontinued Data Center Products and Solutions business in North America on April 1st, 2021. ...