title: Python requests not working for a website API but works in Browser (chrome)
body: <p>Python requests not working for a website API but works in Browser (chrome). it used to work earlier but from the past 2 months its not working. the api i am using is yts.mx api.</p>
  <p>I'll attach the code snippet below:</p>
  <pre><code>import requests
  a = requests.get('https://yts.mx/api/v2/list_movies.json')
  </code></pre>
  <p>This is the error i am getting:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py&quot;, line 670, in urlopen
      httplib_response = self._make_request(
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py&quot;, line 426, in _make_request
      six.raise_from(e, None)
    File &quot;&lt;string&gt;&quot;, line 3, in raise_from
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py&quot;, line 421, in _make_request
      httplib_response = conn.getresponse()
    File &quot;D:\Programs\Python\Python39\lib\http\client.py&quot;, line 1347, in getresponse
      response.begin()
    File &quot;D:\Programs\Python\Python39\lib\http\client.py&quot;, line 307, in begin
      version, status, reason = self._read_status()
    File &quot;D:\Programs\Python\Python39\lib\http\client.py&quot;, line 268, in _read_status
      line = str(self.fp.readline(_MAXLINE + 1), &quot;iso-8859-1&quot;)
    File &quot;D:\Programs\Python\Python39\lib\socket.py&quot;, line 704, in readinto
      return self._sock.recv_into(b)
    File &quot;D:\Programs\Python\Python39\lib\ssl.py&quot;, line 1241, in recv_into
      return self.read(nbytes, buffer)
    File &quot;D:\Programs\Python\Python39\lib\ssl.py&quot;, line 1099, in read
      return self._sslobj.read(len, buffer)
  TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;D:\Programs\Python\Python39\lib\site-packages\requests\adapters.py&quot;, line 439, in send
      resp = conn.urlopen(
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py&quot;, line 726, in urlopen
      retries = retries.increment(
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py&quot;, line 410, in increment
      raise six.reraise(type(error), error, _stacktrace)
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\packages\six.py&quot;, line 734, in reraise
      raise value.with_traceback(tb)
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py&quot;, line 670, in urlopen
      httplib_response = self._make_request(
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py&quot;, line 426, in _make_request
      six.raise_from(e, None)
    File &quot;&lt;string&gt;&quot;, line 3, in raise_from
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py&quot;, line 421, in _make_request
      httplib_response = conn.getresponse()
    File &quot;D:\Programs\Python\Python39\lib\http\client.py&quot;, line 1347, in getresponse
      response.begin()
    File &quot;D:\Programs\Python\Python39\lib\http\client.py&quot;, line 307, in begin
      version, status, reason = self._read_status()
    File &quot;D:\Programs\Python\Python39\lib\http\client.py&quot;, line 268, in _read_status
      line = str(self.fp.readline(_MAXLINE + 1), &quot;iso-8859-1&quot;)
    File &quot;D:\Programs\Python\Python39\lib\socket.py&quot;, line 704, in readinto
      return self._sock.recv_into(b)
    File &quot;D:\Programs\Python\Python39\lib\ssl.py&quot;, line 1241, in recv_into
      return self.read(nbytes, buffer)
    File &quot;D:\Programs\Python\Python39\lib\ssl.py&quot;, line 1099, in read
      return self._sslobj.read(len, buffer)
  urllib3.exceptions.ProtocolError: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;D:\Programs\Python\Python39\test.py&quot;, line 8, in &lt;module&gt;
      a = r.get('https://yts.mx/api/v2/list_movies.json')
    File &quot;D:\Programs\Python\Python39\lib\site-packages\requests\api.py&quot;, line 76, in get
      return request('get', url, params=params, **kwargs)
    File &quot;D:\Programs\Python\Python39\lib\site-packages\requests\api.py&quot;, line 61, in request
      return session.request(method=method, url=url, **kwargs)
    File &quot;D:\Programs\Python\Python39\lib\site-packages\requests\sessions.py&quot;, line 530, in request
      resp = self.send(prep, **send_kwargs)
    File &quot;D:\Programs\Python\Python39\lib\site-packages\requests\sessions.py&quot;, line 643, in send
      r = adapter.send(request, **kwargs)
    File &quot;D:\Programs\Python\Python39\lib\site-packages\requests\adapters.py&quot;, line 498, in send
      raise ConnectionError(err, request=request)
  requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))
  </code></pre>
  <p>and sometimes getting error like forcibly closed due to existing connection, this is the trace:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py&quot;, line 670, in urlopen
      httplib_response = self._make_request(
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py&quot;, line 381, in _make_request
      self._validate_conn(conn)
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py&quot;, line 978, in _validate_conn
      conn.connect()
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\connection.py&quot;, line 362, in connect
      self.sock = ssl_wrap_socket(
    File &quot;D:\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py&quot;, line 386, in ssl_wrap_socket
      return context.wrap_socket(sock, server_hostname=server_hostname)
    File &quot;D:\Programs\Python\Python39\lib\ssl.py&quot;, line 500, in wrap_socket
      return self.sslsocket_class._create(
    File &quot;D:\Programs\Python\Python39\lib\ssl.py&quot;, line 1040, in _create
      self.do_handshake()
    File &quot;D:\Programs\Python\Python39\lib\ssl.py&quot;, line 1309, in do_handshake
      self._sslobj.do_handshake()
  ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
  </code></pre>
  <p>This used to perfectly work a month ago or so. Tried various methods seen on web.</p>
  <p><em><strong>UPDATE</strong></em></p>
  <p>Turns out the issue is with the IP . When i use a VPN connection it works perfectly. However i dont need a VPN to access it from my web browser. any Idea why this is happening?
  is there a way to bypass this?</p>