Skip to content

Loopback host address ('localhost','127.0.0.1', etc.) resolves to network IP #1367

@tonyghita

Description

@tonyghita

Expected behavior

I have my Jedis client configured to connect to localhost.
I expect the connection to be made to the localhost via loopback.

Actual behavior

As of the changes in #1342, when specifying a localhost address, it now resolves to my machine's network ip address.

This makes it impossible to connect to a redis-sentinel on localhost because the sentinel only allows connections from loopback on more recent versions of Redis.

Steps to reproduce:

  1. Initialize a Jedis 2.9.+ client with the host 'localhost'
  2. Unable to connect to local redis-sentinel (version 3.2.2) because 'localhost' resolved to an external ip (i.e. 10.1.10.254).

I think the new behavior in getLocalHostQuietly() introduces system-dependent behavior via InetAddress.getLocalHost().getHostAddress(), which does not seem to be the intent of the code.

Redis / Jedis Configuration

Jedis version:

2.9.x (since #1342)

Redis version:

3.2.2

Java version:

java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions