LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 03-24-2015, 07:26 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Rep: Reputation: 33
[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?
 
Old 03-24-2015, 07:29 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,413

Rep: Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540
sendmail/postfix not running or not configured to listen on localhost

Last edited by TenTenths; 03-24-2015 at 07:35 AM.
 
Old 03-24-2015, 07:32 AM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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).
 
Old 03-24-2015, 07:38 AM   #4
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
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)
 
Old 03-24-2015, 07:40 AM   #5
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by TenTenths View Post
sendmail/postfix not running or not configured to listen on localhost

which postfix do you mean?
 
Old 03-24-2015, 08:39 AM   #6
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,413

Rep: Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540
Quote:
Originally Posted by thomas2004ch View Post
which postfix do you mean?
postfix the main alternative mail server to sendmail
 
Old 03-24-2015, 09:09 AM   #7
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by TenTenths View Post
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?
 
Old 03-24-2015, 09:19 AM   #8
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,413

Rep: Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540
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
 
Old 03-24-2015, 09:22 AM   #9
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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
 
Old 03-25-2015, 02:29 AM   #10
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
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?
 
Old 03-25-2015, 02:48 AM   #11
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
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.
 
Old 03-25-2015, 02:59 AM   #12
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,413

Rep: Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540
Quote:
Originally Posted by thomas2004ch View Post
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 View Post
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 View Post
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.
 
Old 03-25-2015, 03:21 AM   #13
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
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.
 
Old 03-25-2015, 03:28 AM   #14
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,413

Rep: Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540Reputation: 1540
Quote:
Originally Posted by thomas2004ch View Post
This means no mail service is running?
Correct.

Quote:
Originally Posted by thomas2004ch View Post
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".
 
Old 03-25-2015, 03:34 AM   #15
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
Smile

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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
connect to 127.0.0.1[127.0.0.1]: Connection refused (port 10024) adamos22 Linux - Newbie 2 07-31-2013 12:40 PM
"telnet: connect to address 127.0.0.1: Connection refused" bushwacker03 Linux - Newbie 6 03-04-2013 08:42 PM
telnet: connect to address ::1: Connection refused kahafil Linux - Enterprise 1 06-04-2012 12:14 PM
[SOLVED] Another one . . . . telnet: connect to address 127.0.0.1: Connection refused verWire3619 Linux - Networking 2 09-02-2011 01:49 PM
telnet:connect to address 127.0.0.1: connection refused sdeven Linux - Networking 6 12-23-2002 12:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration