This code generates errors only on Mac OSX

When I run the following code in windows 10 and fedora it works without error but on Mac OSX Sierra it throws up errors. Since it only happens on my Mac I am assuming its a bug. I will paste the errors below.

```python
import json
import operator
import requests

url = "https://data.ny.gov/resource/h6w8-42p9.json?$limit=3000"
data = requests.get(url).json()





###################################################
#errors here
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 326, in connect
    ssl_context=context)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/util/ssl_.py", line 324, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 377, in wrap_socket
    _context=self)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 752, in __init__
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 988, in do_handshake
    self._sslobj.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 633, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [Errno 54] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/util/retry.py", line 347, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 326, in connect
    ssl_context=context)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/util/ssl_.py", line 324, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 377, in wrap_socket
    _context=self)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 752, in __init__
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 988, in do_handshake
    self._sslobj.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 633, in do_handshake
    self._sslobj.do_handshake()
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 8, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/adapters.py", line 473, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
```

Thanks for this report!

Unfortunately, this issue is caused because the Python versions installed from python.org are linked against the OpenSSL that is shipped by Apple in macOS. This OpenSSL is ancient, and supports almost no modern cipher suites, making it essentially impossible to use securely. This will cause a number of these problems.

The easiest way to solve this problem for the moment is to `pip install pyopenssl idna`. That will let us use a newer OpenSSL, which should resolve the problem.

@Lukasa, this patch is not helping. `pip install pyopenssl idna`.

Still facing the following error on Mac.

```
requests.exceptions.ConnectionError: ('Connection aborted.', error(54, 'Connection reset by peer'))
```

Same python script works on Ubuntu but not on Mac.

Can you provide the output from `python -m requests.help`?

@Lukasa updated the requests module, which resolved the issue.

Anyway, this is the output of `python -m requests.help`

```
{
  "chardet": {
    "version": "3.0.4"
  }, 
  "cryptography": {
    "version": "2.0.3"
  }, 
  "idna": {
    "version": ""
  }, 
  "implementation": {
    "name": "CPython", 
    "version": "2.7.10"
  }, 
  "platform": {
    "release": "15.6.0", 
    "system": "Darwin"
  }, 
  "pyOpenSSL": {
    "openssl_version": "1010006f", 
    "version": "17.2.0"
  }, 
  "requests": {
    "version": "2.18.3"
  }, 
  "system_ssl": {
    "version": "9081df"
  }, 
  "urllib3": {
    "version": "1.22"
  }, 
  "using_pyopenssl": true
}
```

Thanks for getting back.

I've also encountered the same issue, and the patch is also not work.

```
 {
 	"chardet": {
 		"version": "3.0.4"
 	},
 	"cryptography": {
 		"version": "2.0.3"
 	},
 	"idna": {
 		"version": "2.6"
 	},
 	"implementation": {
 		"name": "CPython",
 		"version": "2.7.10"
 	},
 	"platform": {
 		"release": "16.6.0",
 		"system": "Darwin"
 	},
 	"pyOpenSSL": {
 		"openssl_version": "1010006f",
 		"version": "17.2.0"
 	},
 	"requests": {
 		"version": "2.18.3"
 	},
 	"system_ssl": {
 		"version": "9081df"
 	},
 	"urllib3": {
 		"version": "1.22"
 	},
 	"using_pyopenssl": true
 }
```

```
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
socket.error: [Errno 54] Connection reset by peer
```

@IAmFQQ In *your* case this is probably related to the server you're contacting not supporting an appropriately recent version of TLS. Can you share the hostname of the server you're contacting? If not, try the patch from [here](https://lukasa.co.uk/2017/02/Configuring_TLS_With_Requests/).

@Lukasa  Thanks for your support. The hostname is a company internal address that I can't share with you. But I can get response by postman. 
Thanks Lukasa.


I faced the same error in my mac and I solved it by upgrading requests version from 2.7.0 to 2.18.4

I've also encountered the same issue, and the patch is also not working.

Looking at python -m requests.help I see "using_pyopenssl": false. How do I fix this?

````
$ python -m requests.help
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.6"
  },
  "implementation": {
    "name": "CPython",
    "version": "2.7.10"
  },
  "platform": {
    "release": "16.7.0",
    "system": "Darwin"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.18.4"
  },
  "system_ssl": {
    "version": "9081df"
  },
  "urllib3": {
    "version": "1.22"
  },
  "using_pyopenssl": false
}`
```

Hi there @nnayar . Unfortunately, it seems this is a request for help instead of a report of a defect in the project. Please use [StackOverflow](https://stackoverflow.com) for general usage questions instead and only report defects here. Please also do not revive issues that have been closed for a significant period of time.

please check the port number that you are using for RPC.
we have two ports one for block chain and one for RPC
you can get this RPC port where you started the multichain..
G:\data64>multichaind chain0 -daemon

MultiChain 1.0.5 Daemon (latest protocol 10011)

Other nodes can connect to this node using:
multichaind chain0@192.168.137.106:2909

Listening for API requests on port **2908** (local only - see rpcallowip setting)

Node ready.

Installed the above mentioned 

`pip install pyopenssl idna`

And still getting 

> ConnectionError: ('Connection aborted.', error(54, 'Connection reset by peer'))

for both iPython and my default installed Python 2.7.10

`$ python -m requests.help`
> {
>   "chardet": {
>     "version": "3.0.4"
>   }, 
>   "cryptography": {
>     "version": ""
>   }, 
>   "idna": {
>     "version": "2.6"
>   }, 
>   "implementation": {
>     "name": "CPython", 
>     "version": "2.7.10"
>   }, 
>   "platform": {
>     "release": "14.5.0", 
>     "system": "Darwin"
>   }, 
>   "pyOpenSSL": {
>     "openssl_version": "", 
>     "version": null
>   }, 
>   "requests": {
>     "version": "2.18.4"
>   }, 
>   "system_ssl": {
>     "version": "9081df"
>   }, 
>   "urllib3": {
>     "version": "1.22"
>   }, 
>   "using_pyopenssl": false
> }




And getting this error:

> ConnectionError: ('Connection aborted.', error(54, 'Connection reset by peer'))


I seem to have more recent versions of openSSL installed:
`$ ls /usr/local/Cellar/openssl/1.0.2`

> 1.0.2d_1/ 1.0.2h_1/ 1.0.2l/   1.0.2m/   1.0.2n/   1.0.2o_1/ 1.0.2p/


But python is still using:
`$ python -c "import ssl; print ssl.OPENSSL_VERSION"`
>OpenSSL 0.9.8zg 14 July 2015

@carlcrott then this is an issue with how you've installed python and not an issue with requests. For general purpose Q&A please use stackoverflow.