Search code examples
javanetwork-programmingtelnettelnetlib

Telnet works for localhost however not for the raw IP address


I'm running a socket on my Mac laptop and when I telnet the IP address of my computer it says (IP is hidden for security reasons):

telnet 7-.---.--.--- 4005  
Trying 7-.---.--.---...  
telnet: connect to address 7-.---.--.---: Connection refused  
telnet: Unable to connect to remote host  

However when I do telnet on "localhost" it works it says (did not hide any info this is the raw message):

Trying ::1...  
telnet: connect to address ::1: Connection refused  
Trying fe80::1...  
telnet: connect to address fe80::1: Connection refused  
Trying 127.0.0.1...  
Connected to localhost.  

Update - Opened Firewall

Now after opening all of the ports localhost still works the same way as before however when I try the raw IP I get this new error:

Trying 7-.---.--.---...  
telnet: connect to address 7-.---.--.---: Operation timed out  
telnet: Unable to connect to remote host  

Solution

  • Probably a firewall: generally localhost is not barred, but the external IP interface is.