I have a Java server and client, which is a simple server that prints a message when the client communicates with it. It works perfectly fine when the client and server are on the same machine. When I place the client on a different machine I get the following exception:
java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at java.net.Socket.connect(Socket.java:528) at java.net.Socket.<init>(Socket.java:425) at java.net.Socket.<init>(Socket.java:208) at DateClient.main(DateClient.java:16)
I tried running the server on a different machine(which is not the client), and it works fine. So, there is something about the machine that won't allow the client to connect to the port. I tried pinging the server from the client and it's able to reach the server. I switched off the firewall using
sudo /etc/init.d/iptables stop but the client still can't connect to the server. Any help would be appreciated!