aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes java.net.ConnectionException Connection refused to: hostname problem with Linux and Windows solution Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "java.net.ConnectionException Connection refused to: hostname problem with Linux and Windows solution" Watch "java.net.ConnectionException Connection refused to: hostname problem with Linux and Windows solution" New topic
Author

java.net.ConnectionException Connection refused to: hostname problem with Linux and Windows solution

Ulises Pulido
Ranch Hand

Joined: Jul 24, 2008
Posts: 81
Hello

I found out that some of you have had problems with this, and believe it or not this is not an RMI issue and does not involve Java code.

The problem is the Linux machine. To make it work I had to do the following:

First open the port in the Linux machine using the following iptables command as root:

iptables -A OUTPUT -p tcp -d 0/0 -s 0/0 --dport 1099 -j ACCEPT
iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 1099 -j ACCEPT

after that you have to check your hostname file and see what is it:

cat /etc/hostname

for instance my hostname was:

ulises-machine

next you have to specify this name as the name to retrieve when someone asks you for your hostname. This can be done modifying your /etc/hosts file

vi /etc/hosts

now you need to change this file adding the following

192.168.42.128 ulises-machine.localdomain ulises-machine

of course that you have to put your own hostname and IP address.

The next and final step is to reboot the networking services

/etc/init.d/networking restart

Start your server again and try to connect to it using your client and it should work fine.

I hope this helps


SCJP 5.0, SCWCD 5.0, SCBCD 5.0, SCJD, SCEA in progress
www.ulisespulido.com
Ulises Pulido
Ranch Hand

Joined: Jul 24, 2008
Posts: 81
whoops I forgot to mention

If you have an already set value in /etc/hosts with your server hostname comment it using # usually it has something like:

127.0.0.1 machine.localdomain machine

just comment this and add what I said in the previous post.


Regards!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.net.ConnectionException Connection refused to: hostname problem with Linux and Windows solution
 
Similar Threads
How to configure jBoss(5.x or above) to accept incoming requests through another machine?
Waiting for Tomcat to shut down
Facing problem while accessing tomcat on a dedicated hosting Linux server
Ports
ServerSocket IP address?