Hostname resolution slow

When making a request to a hostname it is very slow. In my case I have multiple docker containers with different services that communicate using requests. Every container has it's own cherrypy server and is adressed like so: `requests.get('http://main:8083')` or `requests.get('http://controller:8082')`. The docker version is `Docker version 18.03.1-ce, build 9ee9f40` on Ubuntu 18.04 LTS. All containers are part of a compose stack and have a common network created by docker-compose.

I've written a small bench application since the problem also exists on my host machine running windows and trying to get a localhost page.

The request work just fine when using the ip address (127.0.0.1) in this case but that is not an option since the ip's of the containers might change.

Weirdly however I don't have the problem on the host machine of the docker daemon. If I run my bench program on there (Ubuntu 18.04 LTS) it works just fine with `localhost` and `127.0.0.1`.

bench.py
```python
import http.client
from math import floor
import urllib3
import requests
from time import time
import socket


def print_with_dashes(text: str, length: int = 50, symbol: str = '-'):
    text_len = len(text)
    part = length - text_len
    if part % 2 == 1:
        part = floor(part / 2)
        print(symbol * part + text + symbol * part)
    else:
        part = floor(part / 2)
        print(symbol * part + text + symbol * (part - 1))


print_with_dashes('urllib3')
urllib_3 = urllib3.PoolManager()
pre = time()
urllib_3.request('GET', 'http://localhost')
print('localhost:', time() - pre)
pre = time()
urllib_3.request('GET', 'http://127.0.0.1')
print('127.0.0.1:', time() - pre)

# ---------------------------------------------------

print_with_dashes('requests')
pre = time()
requests.get('http://localhost')
print('localhost:', time() - pre)
pre = time()
requests.get('http://127.0.0.1')
print('127.0.0.1:', time() - pre)

# ---------------------------------------------------

print_with_dashes('requests with session')
session = requests.session()
session.trust_env = False
session.proxies = {
    'http': None
}
pre = time()
session.get('http://localhost')
print('localhost:', time() - pre)
pre = time()
session.get('http://127.0.0.1')
print('127.0.0.1:', time() - pre)

# ---------------------------------------------------

# testing if it might be caching
print_with_dashes('requests repeated x3')
pre = time()
for i in range(0, 3):
    requests.get('http://localhost')
print('localhost:', time() - pre)
pre = time()
for i in range(0, 3):
    requests.get('http://127.0.0.1')
print('127.0.0.1:', time() - pre)

# ---------------------------------------------------

print_with_dashes('http.client.HTTPConnection')
pre = time()
conn = http.client.HTTPConnection("localhost", 80)
conn.request("GET", "/")
print('localhost:', time() - pre)
pre = time()
conn = http.client.HTTPConnection("127.0.0.1", 80)
conn.request("GET", "/")
print('127.0.0.1:', time() - pre)

# ---------------------------------------------------

print()
print_with_dashes('Possible Solutions', symbol='#')
print_with_dashes('socket.gethostbyname')
pre = time()
address = socket.gethostbyname('localhost')
requests.get('http://' + address)
print('localhost:', time() - pre)
pre = time()
address = socket.gethostbyname('127.0.0.1')
requests.get('http://' + address)
print('127.0.0.1:', time() - pre)
```

server.py
```python
import cherrypy


class HelloWorld(object):
    @cherrypy.expose
    def index(self):
        return "Hello World"


cherrypy.config.update({'server.socket_port': 80})
cherrypy.quickstart(HelloWorld())
```

Closing this as it seems to be windows related and only appears at random times.
To any one having the same issues i would recommend resolving the hostname with socket.gethostbyname() (ipv4 only!) or socket.gethostbyaddr() (ipv4 and ipv6) this will resolve the ip in <0.01s and the request will be equally as fast using the ip address.