Forums Register Login

Want to connect to computer over internet. Getting exception- Connection refused:connect

+Pie Number of slices to send: Send
I want to create a simple chat program which can work through internet not only in local network. I started from basics and created two simple client and server program which on connecting shares one message. The java program works fine when testing on local network but when testing it through internet it gives exception "Connection refused: connect".

I'm testing on one PC (although I've tried it on two computers, but it didn't worked).
Server programs starts at port 5000. Client programs connects with Server by providing dynamic internet IP of server. Client also knows the port number.

Server Program:


Client Program:


What I've tried yet:
Tried disabling firewall and avast antivirus.
Done port forwarding into my router.
Tested telnet, it calls my modem home page, when called with dynamic IP.
Also, I tested it removing router and connecting directly to modem. But still getting exception.
Program is working in local network.

Please Help, I'm new to networking.
+Pie Number of slices to send: Send
Let's do a check...
Change:

To:

See if there is any errors then. Remember to have the server running BEFORE you run the client...
John Price aka cc11rocks
+Pie Number of slices to send: Send
I have already mentioned that it is working in local network. So localhost or computer name or 192.168.X.X is working.
Also I haven't tested it outside my network i.e I tried running this program using 2 computers, but they are in the same network, hence their dynamic IP will be same. Although I port forwarded it, but no result. Should I try running client program outside my network?
+Pie Number of slices to send: Send
It should easily run inside your network. Will take a look at it later today when I get home...
John Price aka cc11rocks
+Pie Number of slices to send: Send
I tried "netstat -a" to see where it is running and listening in my local network. And it was listening to 0.0.0.0:5000, I though it might be a problem and binded it with my local network address which is 192.168.0.102. And now it is listening to 192.168.0.102:5000.
But now the problem is, this is the local address. In Foreign Address, the "netstat -a" shows "HARISH:0", the name of the computer is OK but the port number is 0. What does this means?
+Pie Number of slices to send: Send
The problem is solved.
Problem was not in my program, but in port forwarding, my modem is also a router and it was blocking incoming connection making them unable to reach to my router.
I took help from http://forum.pcwintech.com website's forum. Awesome website admins are wiling to help anytime. Anyone has networking related problem can refer to this site.
Here is my forum post link, if anyone has this issue.
Problem in Port Forwarding
So you made a portal in time and started grabbing people. This tiny ad thinks that's rude:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 6554 times.
Similar Threads
ServerSocket problem w/ Jeode EVM on iPaq
A good, simple tutorial for making sockets work over the Internet.
Dynamic IP address and socket programming.
Need Server to know name of Transfering File
Help need for client server program
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:19:00.