Subdomain that ends with dash works in OSX but not Linux

For example the URL dev-.domain.com would work in OSX but not Linux. The URL dev-sub.domain.com works in both. The problem occurs in both requests 2.1.0 and 2.3.0.


Wow, this is a specific problem. When you say "Doesn't work", what exactly does that mean?


I am pretty sure labels ending with a dash are forbidden. I'll look into the spec


I get the Max retries exceeded exception.


@feus4177 Can you provide the entire traceback, including the full text of the exception?


This seems oddly specific and more bizarrely unlikely. Do you have something in your `/etc/hosts` on OSX that you don't have on Linux?


The only reason I brought up that it works on OSX is just that I thought it might be helpful in troubleshooting what's going on. I believe everything in /etc/hosts is default.

Traceback:

```
>>> requests.get('https://dev-.skyforge.co')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 55, in get
    return request('get', url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 382, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 485, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 372, in send
    raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='dev-.skyforge.co', port=443): Max retries exceeded with url: / (Caused by <class 'socket.gaierror'>: [Errno -2] Name or service not known)
```

/etc/hosts for Linux:

```
127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

127.0.1.1       raspberrypi
```

/etc/hosts for OSX:

```
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
```


I finally got around to testing this on a linux box. It helped me realize the important part of the exception `Caused by <class 'socket.gaierror'>: [Errno -2] Name or service not known` (also I assume not staring at this for a day or two helped too). Namely `socket.gaierror` is raised when using `socket.getaddrinfo`. If you were to open up an interactive console and you did

``` pycon
>>> import socket
>>> socket.getaddrinfo('dev-.skyforge.co', 443)
```

You'll get an exception. On OS X you should instead see a list returned of tuples, e.g.,

``` python
[(2, 2, 17, '', ('198.199.118.90', 443)), (2, 1, 6, '', ('198.199.118.90', 443))]
```

With that said, there's nothing we can do to fix this since it is strictly based on how your machine implements the API defined in `<socket.h>` which the `socket` module wraps for Python. Sorry, but this isn't a bug in requests.


Ah, I see. Thanks for your help. 'ppreciate it.


## Sorry we can't really be more helpful. If you find out why this happens feel free to comment here and let us know

Sent from my Android device with K-9 Mail. Please excuse my brevity.