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 => "" 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 straceing reveals that it's failing here:

connect(13, {sa_family=AF_INET6, sin6_port=htons(6379), inet_pton(AF_INET6, "::ffff:", &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)
  • Can you please paste the configs you are using in logstash – GeekRide Mar 18 '13 at 12:55
  • There's not much more to my config than what I've posted... and the answer turned out to be nothing to do with logstash (see my answer). – Flup Mar 18 '13 at 14:43

This is caused by this bug: the sysctl setting net.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

$ sudo sysctl -w net.ipv6.bindv6only=0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.