Linux - Software This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
|
03-24-2015, 07:26 AM
|
#1
|
Member
Registered: Aug 2009
Posts: 539
Rep:
|
[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
What could be the reason?
|
|
|
03-24-2015, 07:29 AM
|
#2
|
Senior Member
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7 / 8
Posts: 3,572
|
sendmail/postfix not running or not configured to listen on localhost
Last edited by TenTenths; 03-24-2015 at 07:35 AM.
|
|
|
03-24-2015, 07:32 AM
|
#3
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
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).
|
|
|
03-24-2015, 07:38 AM
|
#4
|
Member
Registered: Aug 2009
Posts: 539
Original Poster
Rep:
|
As I run the " lsof -i :25", I got nothing. This means there is problem?
But the other machine where the telnet works, I got response as follow:
Code:
]# lsof -i :25
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
master 2745 root 11u IPv4 9936 0t0 TCP localhost.localdomain:smtp (LISTEN)
java 15132 root 589u IPv4 325729 0t0 TCP localhost.localdomain:36848->localhost.localdomain:smtp (ESTABLISHED)
java 15132 root 593u IPv4 323371 0t0 TCP localhost.localdomain:36812->localhost.localdomain:smtp (ESTABLISHED)
|
|
|
03-24-2015, 07:40 AM
|
#5
|
Member
Registered: Aug 2009
Posts: 539
Original Poster
Rep:
|
Quote:
Originally Posted by TenTenths
sendmail/postfix not running or not configured to listen on localhost
|
which postfix do you mean?
|
|
|
03-24-2015, 08:39 AM
|
#6
|
Senior Member
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7 / 8
Posts: 3,572
|
Quote:
Originally Posted by thomas2004ch
which postfix do you mean?
|
postfix the main alternative mail server to sendmail
|
|
|
03-24-2015, 09:09 AM
|
#7
|
Member
Registered: Aug 2009
Posts: 539
Original Poster
Rep:
|
Quote:
Originally Posted by TenTenths
postfix the main alternative mail server to sendmail
|
where locate this file? I find there are several postfix files. But which one should I look into?
|
|
|
03-24-2015, 09:19 AM
|
#8
|
Senior Member
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7 / 8
Posts: 3,572
|
First of all check which mail server you think should be running.
If it's postfix then google it, there's tons of help and how-tos around.
The main config file is main.cf
|
|
|
03-24-2015, 09:22 AM
|
#9
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
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).
master is the name of the main Postfix mailer daemon. You can see more details about it at:
http://linux.die.net/man/5/master
|
|
|
03-25-2015, 02:29 AM
|
#10
|
Member
Registered: Aug 2009
Posts: 539
Original Poster
Rep:
|
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.
And I tired 'ps -ef |grep 2745' and I get:
Code:
# ps -ef |grep 2745
root 8813 6541 0 08:29 pts/0 00:00:00 grep 2745
This should ok as well? But where could be the probelm?
|
|
|
03-25-2015, 02:48 AM
|
#11
|
Member
Registered: Aug 2009
Posts: 539
Original Poster
Rep:
|
Besides, as I run command 'netstat -ntpl |grep "127.0.0.1"', I got
Code:
# netstat -ntpl |grep "127.0.0.1"
tcp 0 0 127.0.0.1:2528 0.0.0.0:* LISTEN 32065/java
tcp 0 0 127.0.0.1:4449 0.0.0.0:* LISTEN 32065/java
tcp 0 0 127.0.0.1:7079 0.0.0.0:* LISTEN 32065/java
tcp 0 0 127.0.0.1:4455 0.0.0.0:* LISTEN 32065/java
tcp 0 0 127.0.0.1:6990 0.0.0.0:* LISTEN 32065/java
tcp 0 0 127.0.0.1:3447 0.0.0.0:* LISTEN 32065/java
tcp 0 0 127.0.0.1:6999 0.0.0.0:* LISTEN 32065/java
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2791/cupsd
Seems the port 25 is not opened.
By another machine I got:
Code:
]# netstat -ntpl |grep "127.0.0.1"
...
tcp 0 0 127.0.0.1:3447 0.0.0.0:* LISTEN 21687/java
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2745/master
One can see the port 25 is opened.
|
|
|
03-25-2015, 02:59 AM
|
#12
|
Senior Member
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7 / 8
Posts: 3,572
|
Quote:
Originally Posted by thomas2004ch
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.
If you see something like this:
Code:
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1139/sendmail
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?
Last edited by TenTenths; 03-25-2015 at 03:01 AM.
|
|
|
03-25-2015, 03:21 AM
|
#13
|
Member
Registered: Aug 2009
Posts: 539
Original Poster
Rep:
|
Many thanks for the detail info.
I tried your command 'netstat -lnp | grep 25' and get:
Code:
# netstat -lnp | grep 25
tcp 0 0 127.0.0.1:2528 0.0.0.0:* LISTEN 32065/java
udp 0 0 fe80::250:56ff:feaf:2a1b:123 :::* 2812/ntpd
This means no mail service is running?
Following is the OS:
Code:
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.11 (Tikanga)
The configuration on this machine is not done by me.
|
|
|
03-25-2015, 03:28 AM
|
#14
|
Senior Member
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7 / 8
Posts: 3,572
|
Quote:
Originally Posted by thomas2004ch
This means no mail service is running?
|
Correct.
Quote:
Originally Posted by thomas2004ch
The configuration on this machine is not done by me.
|
So are you now responsible for admin on it?
Try this:
and see if you can see entries for either POSTFIX or SENDMAIL in the first column.
If you see entries and then things like 0  ff 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".
|
|
|
03-25-2015, 03:34 AM
|
#15
|
Member
Registered: Aug 2009
Posts: 539
Original Poster
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 09:47 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|