Requests lib works in Window and times out in Linux
<p>I have a simple python script to make a POST operation using requests lib. In windows, it works fine with no problem. In <strong>Linux</strong>, it's <strong>not</strong> working <strong><em>even though I can ping</em></strong>. The script gives me in Linux:</p>

<pre><code>Traceback (most recent call last):
  File "temp.py", line 55, in &lt;module&gt;
    r = requests.post(urlPOST, json=payLoad, auth=('admin', 'pass'), verify=False)
  File "/opt/ute/python/lib/python2.7/site-packages/requests/api.py", line 109, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/opt/ute/python/lib/python2.7/site-packages/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/opt/ute/python/lib/python2.7/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/ute/python/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/opt/ute/python/lib/python2.7/site-packages/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(110, 'Connection timed out'))
</code></pre>

<p>Again, <strong><em>I can ping</em></strong> the site <em>with no problems</em> in Linux. </p>

<p><strong><em>Questions:</em></strong> <strong>1- What my be wrong?</strong>
<strong>2- Is there another way to check connection rather than ping?</strong> I mean if it was a proxy problem, then I wouldn't be able to ping as well, right?</p>

<p>My guess is, the website is not responding to your request, and that's why you are getting a time out error. I will try to solve this by changing the user agent in the header, because some websites might be trying to avoid bots. Maybe try something like this:  </p>

<pre><code>header = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebK it/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36'}
r = requests.post(urlPOST, headers=header, json=payLoad, auth=('admin', 'pass'), verify=False)
</code></pre>

python linux python-2.7 proxy python-requests