Service is not running
Another reason for the “connection refused” error is that there is no service listening on the port you are trying to connect to.
For example, web servers typically listen for connections on port 80 for HTTP. If you try to connect to port 80 with Telnet, but the web server program is not running, you will get the error.
Error :
telnet xx.xx.xxx.xxx 80
Trying xx.xx.xxx.xxx...
telnet: Unable to connect to remote host: Connection refused
How to Fix This Error :
First check if the service you want to connect to is actually running on the server. On Linux, we can check if the HTTP service is running with the Below Command.
Command :
ps aux | grep HTTP
Output :
We also verify which port the service is listening to. The “netstat“ command shows which ports programs on the server are listening on.
Command :
sudo netstat -lnpt | grep :80
Output :
This tells us the exact port and IP address the HTTP service is bound to. If the customer is using the wrong port number or IP address in their Telnet command, we provide the correct details to connect to the running service. Using the working port and IP will fix the “connection refused” error.
How To Solve Telnet Connection Refused By Remote Host In Linux
Wanted to access a remote server over Telnet but got “connection refused” errors? This is a common problem that can leave you stranded when trying to handle Linux systems from afar. Failure to initiate a Telnet session locks you out of administrating and diagnosing problems on servers, networking equipment and other devices.
The good news is that often these “connection refused” errors are easy to resolve with just some basic checks. In this simple, step-by-step guide, we will get to know how to quickly get Telnet working again. By tweaking firewall rules, fixing network/port settings, and checking for connectivity issues one can have Telnet sessions up in no time. The above couple of small changes will take care of the irritating connection-related difficulties and allow remote reentry into your Linux-based gadgets in an effortless way.