when I run '(sleep 1; echo flush_all; sleep 1; echo quit; ) | telnet localhost 11211'
I get
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
OK
Connection closed by foreign host.
The above command does what I want but what about the ::1
part?
The software listening on port 11211 doesn't support IPv6. Since localhost is an entry in the hosts file that tries an IPv6 address first, you only fail back to IPv4 after IPv6 fails. You can solve the issue by either getting the software updated (or properly configured to listen on IPv6 if it's an option in the config file) or changing your command to
telnet 127.0.0.1
instead oftelnet localhost
.::1 is the IPv6 loopback address, the equivalent of the IPv4 loopback 127.0.0.1.
To avoid the ipv6 connexion, use the '-4' switch:
The same with '-6' :
It works with a lot of network utilities, like wget, curl, ssh,...