I've just started playing with logstash, and I'm having a problem getting a log shipper process to send events to a redis server on another host.
The output
stanza of my logstash config file reads
output { redis { host => "11.22.33.44" data_type => "list" key => "logstash" } }
However, when I run the logstash process, I get error messages containing
:exception=>#<SocketError: Network is unreachable>
A bit of strace
ing reveals that it's failing here:
connect(13, {sa_family=AF_INET6, sin6_port=htons(6379), inet_pton(AF_INET6, "::ffff:11.22.33.44", &sin6_addr) = -1 ENETUNREACH (Network is unreachable)
i.e. it's trying to connect to the redis host on an ipv6-mapped ipv4 address. The host doesn't have a native ipv6 address and the connection fails.
How can I either get the process to use AF_INET
instead of AF_INET6
, or somehow configure my host to work around the problem?
In case it's relevant, my java version is
java version "1.6.0_18" OpenJDK Runtime Environment (IcedTea6 1.8.13) (6b18-1.8.13-0+squeeze2) OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
This is caused by this bug: the
sysctl
settingnet.ipv6.bindv6only=1
breaks Java networking in Debian squeeze (and probably other platforms).The setting only seems to matter to people who want to distinguish ipv6 and ipv4 connections. I don't really care about this, so I did
started the logstash agent, and it worked!
The creator of logstash kindly told me afterwards that you can also add
-Djava.net.preferIPv4Stack=true
to the command line.