[SOLVED] [LINUX] telnet: connect to address 127.0.0.1: Connection refused
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
[LINUX] telnet: connect to address 127.0.0.1: Connection refused
Hi,
I have problem by sending email. So I try the following:
Code:
telnet localhost 25
But I got error as follow:
Code:
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
The content of the /etc/hosts is follow:
Code:
]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
The most obvious would be that port 25 isn't LISTENing.
Run "lsof -i :25" to see if it is. Typically you'd need a mail program like Sendmail or Postfix to be LISTENing on that port.
If mail is LISTENing you'd want to make sure the port shown by lsof is *:25 (for all interfaces) or 127.0.0.1:25 (or localhost:25) for just localhost.
If the port is LISTENing you'd need to make sure the configuration of your mail program is allowing connections on localhost (which most do by default).
smtp = port 25 (you can verify that by typing "grep smtp /etc/services")
This means your lsof output confirms that localhost is LISTENing on port 25.
Your lsof output also shows you have to java processes connected (ESTABLISHED) to port 25.
In lsof it tells you the LISTENing process is called "master" and its Process ID (PID) is 2745. You can do "ps -ef |grep 2745" to see more details about that process and any parents or children it has. You can also get details in /proc/2745 about the process including its full path (if not shown in the grep).
As I run the " lsof -i :25", I got nothing. This means there is problem?
Yes, it means you don't have a mail server running.
Quote:
Originally Posted by thomas2004ch
Many thanks for your detail info.
I've tried the 'grep smtp /etc/services' and I get:
Code:
# grep smtp /etc/services
smtp 25/tcp mail
smtp 25/udp mail
smtps 465/tcp # SMTP over SSL (TLS)
rsmtp 2390/tcp # RSMTP
rsmtp 2390/udp # RSMTP
Seems ok, since I get the same from another machine where the telnet works.
/etc/services is just a list of services and port numbers it will be pretty much identical on any machine. It has nothing to do with whether a service is running or not.
Quote:
Originally Posted by thomas2004ch
And I tired 'ps -ef |grep 2745' and I get:
Which is the same process number in MensaWater's post. My guess is that you just copied and pasted his example which will be irrelevant on your machine.
Another way you can verify you have a mail server running by checking to see if there are any processes listening on port 25
Code:
netstat -lnp | grep 25
If you see something like this:
Code:
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1848/master
This means that POSTFIX is running and listening for mail on port 25. The process id (pid) is 1848.
This means that SENDMAIL is running and listening for mail on port 25. The process id (pid) is 1139
If you don't get one of these two results then it's likely you don't have a mail server running.
For your next post let us know what Linux distro you are using. If you set it up yourself are you sure you installed a mail server and set it to run on startup?
The configuration on this machine is not done by me.
So are you now responsible for admin on it?
Try this:
Code:
chkconfig --list
and see if you can see entries for either POSTFIX or SENDMAIL in the first column.
If you see entries and then things like 0ff and all 0-6 are ff then it's likely that a mailer is installed but not working.
Depending on your infrastructure you may have another server that acts as a mail server for the rest of your environment, if that's the case then you should be configuring your mail client or application to use that server rather than "localhost".
I did further 'chkconfig --list' and I can see postfix is turned on. But as I run 'service postfix status', it shows nothing. Then I try 'service postfix start' and still nothing happens. This means the postfix is deffect.
I am not the admin. But I just told this to the admin. Hope he can repare this.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.