skip to content
Alvin Lucillo

Invalid host with rabbitmqadmin

/ 1 min read

If you’re running rabbitmqadmin and encountered an error with Name or service not known in it, it could be because you’re using the port in --host. In the example below, instead of just the hostname (i.e., localhost), the port was also provided. The correct command should be ./rabbitmqadmin -u someadminuser -p someadminpw --host localhost --port 15672 list queues

./rabbitmqadmin -u someadminuser -p someadminpw --host localhost:15672 list queues

Traceback (most recent call last):
  File "/home/someusser/./rabbitmqadmin", line 632, in http
    conn.request(method, path, body, headers)
  File "/usr/lib/python3.10/http/client.py", line 1283, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1329, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1278, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1038, in _send_output
    self.send(msg)
  File "/usr/lib/python3.10/http/client.py", line 976, in send
    self.connect()
  File "/usr/lib/python3.10/http/client.py", line 942, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.10/socket.py", line 824, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
*** Could not connect: [Errno -2] Name or service not known