Why I can't I telnet to a specific port?
Solution 1
java is listening in 127.0.0.1
, that is localhost.
You can't connect from outside, unless you do some kind of forwarding, using ssh for instance.
Edit:
from external hosts,
if unix/linux
ssh -L 1234:127.0.0.1:7778 runtime
- then from that external host,
telnet 127.0.0.1 1234
(ssh will forward you)
if windows, use putty or bitwise to forward local port 1234 to 7778 on host holding runtime.
Solution 2
The address 127.0.0.1
is the loopback address.
As you have the 127.0.0.1:7788
in the "Local Address" of netstat
output, this means that the connection is only listening for connections originating from this computer only on the loopback interface. No other computers on the network can reach your loopback address directly hence the telnet
is failing from other computers.
Related videos on Youtube
Nadya Nux
Updated on September 18, 2022Comments
-
Nadya Nux over 1 year
the port 7778 is in listen,
netstat -tulpn tcp 0 0 127.0.0.1:7778 0.0.0.0:* LISTEN 22776/java
but I can't telnet that port from remote machine while I can telnet other port by using this command
telnet 192.168.1.100 port_number
-
zhongfu about 9 yearsWhat do you mean "remote machine"? A machine outside your LAN, or a machine in your LAN?
-
Nadya Nux about 9 yearsI mean in the same LAN
-
kubacapek about 9 yearsI am pretty sure its because you are only listening on ip address 127.0.0.1 so only on loopback. You cant connect to that from anywhere.
-
zhongfu about 9 yearsYou said you couldn't "telnet that port" (7778) from the other machine, but what follows that suggests that you could do that. Could you explain what you're doing that doesn't work?
-
Nadya Nux about 9 yearsi edit my question, i meant that i can telnet other ports from remote machine
-
Archemar about 9 yearsthis looks like a XY problem, was java runtime meant to be use from external hosts ? is yes, you should configure it.
-
Nadya Nux about 9 yearsyes it will be used from external hosts, this was my question in comment bellow, how to configure java to listen on IP address instead of localhost to be able to use it from remote machines.
-
heemayl about 9 yearsPlease refrain from asking any X-Y question
-
Nadya Nux about 9 years@heemayl : first time heard about XY question, because i still new here
-
-
Nadya Nux about 9 yearsyes I can only telnet that port from localhost but i can't telnet it from remote host, so howto change it? i mean to use the address it instead of localhost and make it accessible by other machines?
-
Nadya Nux about 9 yearsthere is no way to force java to listen in IP address?
-
Archemar about 9 yearsYou can alway rewrite the part of code that listen(), then recompile. Or ask your Oracle support.