• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ulises Pulido
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ulises Pulido
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic