Website owners often use telnet client as the primary tool to perform basic network connectivity tests.
And, if telnet doesn’t connect to the server, it throws errors that can be hard to understand.
One such error is “telnet localhost 25 connection failed“.
At Bobcares, we help website owners resolve these errors as part of our Support Services.
Today, we’ll discuss the top 4 reasons for this error and how we fix them.
“telnet localhost 25 connection failed” – What this means?
Telnet is used for interactive communication with another host using Telnet protocol. In other words, it enables users to test the server connection to determine the source of the problem. The common syntax of telnet command is given below.
telnet IP_ADDRESS PORT
“telnet localhost 25 connection failed” error means that telnet is waiting to connect to port 25 on localhost, but fails.
And, the complete error message looks like this:
#telnet localhost 25 Connecting To localhost...Could not open connection to the host, on port 25: Connect failed
“telnet localhost 25 connection failed” – Causes and Fixes
We now have a clear understanding of this error. Let’s now see the main reasons for this error and how our Support Engineers fix them.
1) Mail service not running on the server
One of the common reasons for this error is that the email servers such as Postfix, Exim, etc. are not installed/running on the server. And, this problem can happen after server reboots, new server setup, etc.
Service downtime can be due to resource outages, high load, DDoS attacks, disk errors, and more.
Our Hosting Engineers first confirm the status of the email service in the server. For example, we check the status of the Postfix email service with the following command.
ps aux | grep postfix
Alternatively, we use the below command to check the status of the service.
/etc/init.d/postfix status
If the service fails or doesn’t respond, we’ll kill the dead process and restart the service. In addition to that, we check the server logs and fix the reason for the downtime.
On the other hand, if the mail server is not installed, we’ll install it for the customer after analyzing the operating system, system resources, etc.
[Do you need help in recovering a failed service on you server? One of our experienced Server Administrators can help you here.]
2) SMTP port is not open
If the mail service is running on the server, then we must check if the SMTP port is closed or not listening on the server.
Computer ports are the communication end point of computer connected to a network. So, if the email service is not configured to listen on a port, it can’t handle any incoming requests. The default and most frequently used SMTP port is 25.
So, in this case our Support Experts check if anything is listening on port 25 using the netstat command.
netstat -lnp | grep :25
Similarly, in Windows servers, we check whether the SMTP port is specified in the SMTP settings of the MailEnable Management Console.
If not, we’ll add the SMTP port 25 in the mail server settings. For example, in MailEnable, we set the SMTP port from Servers > localhost > Services and Connectors > SMTP > Properties > Inbound tab > Settings > Port Settings.
3) Mail server configuration
Similarly, some web hosts set up mail servers such as Sendmail, Postifx, etc. in such a way that it only accept emails from outside network. For example, server owners mistakenly set Sendmail mail server in a way that it won’t accept connections on the loopback interface(localhost).
As a result, when users try “telnet localhost 25” command, they will get an error like “telnet localhost 25 connection failed” .
So, here our Hosting Engineers correct the mail server configuration to accept connection on loopback interface and external network.
[Worried about messed up mail server configuration on your server? Our Support Experts can fix it for you.]
4) Firewall blocks the connection
If all the above points are fine, the only possibility is that the system firewall blocks the type of connection. Telnet uses port 23 for communication. We’ve seen instances where servers block telnet functionality by adding reject rules on port 23 in the server firewall.
In such cases, our Hosting Engineers first examine the firewall rules on the server. For instance, we use the following command to check the iptables rules on Linux servers.
iptables -nL
After that, we make necessary changes in the firewall configuration to open the port and allow incoming telnet connections.
Conclusion
In short, “telnet localhost 25 connection failed” error can occur due to SMTP service downtime, firewall restrictions, and so on. Today, we’ve discussed the top 4 reasons for this error and how our Support Engineers fix them.
0 Comments