System registration fails with "Name or service not known"

Solution Verified - Updated -

Environment

  • Red Hat Network(RHN)
  • Red Hat Enterprise Linux(RHEL)
  • Red Hat subscription Manager(RHSM)

Issue

  • System registration fails with error Name or service not known :

    Error communicating with server. The message was:
    Name or service not known
    
  • Unable to register system its fails error gaierror: [Errno -2] Name or service not known :

    2014-06-18 14:33:50,133 [ERROR]  @managercli.py:151 - Error during registration: [Errno -2] Name or service not known
    2014-06-18 14:33:50,134 [ERROR]  @managercli.py:152 - [Errno -2] Name or service not known
    Traceback (most recent call last):
      File "/usr/share/rhsm/subscription_manager/managercli.py", line 1045, in _do_command
        owner_key = self._determine_owner_key(admin_cp)
      File "/usr/share/rhsm/subscription_manager/managercli.py", line 1148, in _determine_owner_key
        owners = cp.getOwnerList(self.username)
      File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 852, in getOwnerList
        return self.conn.request_get(method)
      File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 541, in request_get
        return self._request("GET", method)
      File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 448, in _request
        conn.request(request_type, handler, body=body, headers=headers)
      File "/usr/lib64/python2.6/httplib.py", line 914, in request
        self._send_request(method, url, body, headers)
      File "/usr/lib64/python2.6/httplib.py", line 951, in _send_request
        self.endheaders()
      File "/usr/lib64/python2.6/httplib.py", line 908, in endheaders
        self._send_output()
      File "/usr/lib64/python2.6/httplib.py", line 780, in _send_output
        self.send(msg)
      File "/usr/lib64/python2.6/httplib.py", line 739, in send
        self.connect()
      File "/usr/lib64/python2.6/site-packages/M2Crypto/httpslib.py", line 51, in connect
        socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
    gaierror: [Errno -2] Name or service not known
    
  • yum update fails with Error communicating with server. The message was Name or service unknown

Resolution

  • Start the messagebus and haldaemon services, if not running.

  • Check /etc/resolv.conf file to see if the DNS server entry is present in this file. If not, then verify your DNS server and then add its entry.

    # vi /etc/resolv.conf
    
    nameserver <dns_server_ip>
    
  • Check if sslCACert is define properly in /etc/sysconfig/rhn/up2date
    It should be:

      sslCACert=/usr/share/rhn/RHNS-CA-CERT
    
  • Restart network service:

    # service network restart
    

For a system registered with RHSM:

  • Correct Server hostname and Server prefix entries in /etc/rhsm/rhsm.conf file as below:

    [server]
    # Server hostname:
    hostname = subscription.rhn.redhat.com
    
    # Server prefix:
    prefix = /subscription
    
  • Now register system

Root Cause

  • Firewall blocking some ports.
  • Incorrect CA certificate in /etc/sysconfig/rhn/up2date
    For system registered using RHN Classic, value is "sslCACert=/usr/share/rhn/RHNS-CA-CERT"
  • Incorrect Server hostname and Server prefix entries in /etc/rhsm/rhsm.conf file.

Diagnostic Steps

  • From error message it seems that there is an issue with name resolution.

  • Check whether inbound and outbound ports i.e. 443 and 80 are open.

  • To check communication between client and server,

    # telnet xmlrpc.rhn.redhat.com 80
    # telnet xmlrpc.rhn.redhat.com 443
    # nc -z rhn.redhat.com 80 -Xconnect
    # nc -z rhn.redhat.com 443 -Xconnect
    # echo -e "TRACE / HTTP/1.1\nHost: xmlrpc.rhn.redhat.com\n\n" | nc xmlrpc.rhn.redhat.com 80          
    
  • Check whether messagebus and haldaemon services are running:

    # /etc/init.d/messagebus status
    # /etc/init.d/haldaemon status
    

For system registered with Red Hat Subscription Manager

  • Check /etc/rhsm/rhsm.conf file to verify following entries :

    [server]
    # Server hostname:
    hostname = subscription.rhn.redhat.com
    
    # Server prefix:
    prefix = /subscription
    

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

13 Comments

How can I telnet if I can't subscribe? Telnet doesn't appear to be installed by default.

Same here, and the same with nc.

I did everything recommended, except haldaemon is apparently not installed, but I still get this error. I am trying to use via a proxy server.

This is a new install from the distribution iso.

Telnet is also not installed. I tried the nc commands, but it just complains that '-z' is an invalid option.

I also do not have haldaemon installed...

This procedure does not work.

above telnet , nc commands not found and telnet not installed I think.
Above configuration done even no luck

this doesn't work, period. Shame that we pay for this...

Can't even get a Netcat and/or nmap-netcat package for RHEL6 x86_64, even with a RH Subscription. Can't do the recommended troubleshooting.

The documentation also talks about the messagebus and haldaemon daemons, do they need to be on or off? So we don't have enough information there either...

Even if you have proxy set in your up2date and system variables you still also have to have set in your rhsm.conf file. /etc/rhsm/rhsm.conf

an http proxy server to use

proxy_hostname = YOURPROXYHERE

port for http proxy server

proxy_port =YOURPORTHERE

This does not work with a Virtual Host install group image and RHEL 7.x

I suspect it's missing haldaemon.

My problem was a little different. I COULD register, but yum.repo.d wasn't updating with the repository information. I was also getting the Errorno -2 What fixed it for me was to edit /etc/rhsm/rhsm.conf and fill in the values for the proxy server and port. Maybe that helps someone?

This also does not work for me. Telnet is not installed so you can not test the server connections.

HAL daemon not installed under RHEL 7.4 and I can't find a package for it either under the install ISO or under downloads under the Red Hat website.

Also I think the -z flag has been deprecated for nc. When I check nc --help, its no longer listed.