telnet: connect to address 127.0.0.1: Connection refused问题

今天在使用telnet连接本机的Memcached服务时,遇到如下问题:

[root@iZ94imebuqwZ ~]# telnet localhost 11211
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
解决:【请确保memcached已成功安装,且已开启memcached服务】

  1. 检查telnet是否已安装:
    [root@iZ94imebuqwZ ~]# rpm -qa telnet
    telnet-0.17-41.e15     【有输出说明已安装,如果没有输出则没有安装,使用yum install telnet进行安装
  2. 检查telnet-server是否已安装:
    [root@iZ94imebuqwZ ~]# rpm -qa telnet-server
    telnet-server-0.17-41.el5     【有输出说明已安装,如果没有输出则没有安装,使用yum install telnet-server进行安装
  3. 如果第2步进行了telnet-server安装操作,且已成功安装,则由于telnet服务是由xinetd守护的,所以我们需要重新启动xinetd。

    [root@iZ94imebuqwZ ~]# service xinetd restart
    Stopping xinetd:                                          [ OK ]
    Starting xinetd:                                          [ OK ]

  4. xinetd启动成功,可以查看xinetd的运行情况。【非必须
    [root@iZ94imebuqwZ ~]# netstat -tnlp          【或使用netstat -tnl | grep 23只查看目标端口
    Active Internet connections (only servers)
    Proto   Recv-Q   Send-Q   Local Address          Foreign Address         State        PID/Program name  
    tcp          0        0   0.0.0.0:11211          0.0.0.0:*              LISTEN        1866/memcached
    tcp          0        0   0.0.0.0:22             0.0.0.0:*              LISTEN        343/sshd
    tcp          0        0   0.0.0.0:23             0.0.0.0:*              LISTEN        8923/xinetd
    [root@iZ94imebuqwZ ~]#
    [root@iZ94imebuqwZ ~]#
    [root@iZ94imebuqwZ ~]# telnet localhost 23
    Trying ::1...
    Connected to localhost.
    Escape character is '^]'.
    CentOS release 5.10 (Final)
    Kernel 2.6.18-371.11.1.el5 on an x86_64
    login:

  5. 如果仍然无法连接到telnet,需要修改/etc/xinetd.d/telnet文件。【非必须
    [root@iZ94imebuqwZ ~]# vim /etc/xinetd.d/telnet

    # default: on
    # description: The telnet server serves telnet sessions; it uses \
    #       unencrypted username/password pairs for authentication.
    service telnet
    {
            flags           = REUSE
            socket_type     = stream
            wait            = no
            user            = root
            server          = /usr/sbin/in.telnetd
            log_on_failure  += USERID
            #disable                = yes             【将disable=yes行前加#注释掉,或者把yes改为no
    }

    [oot@iZ94imebuqwZ ~]# service xinetd restart

    Stopping xinetd:                                          [ OK ]
    Starting xinetd:                                          [ OK ]

  6. 如果仍然无法连接到telnet,请检查防火墙配置(添加telnet的23端口服务)。防火墙配置请参考Allen.W的有关防火墙配置的文章。

  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值