Develop a python script to perform POST / GET requests to a remote server, using the Requests module. The script is executed successfully by invoking it in the foreground from the command line, that is, manually. However, when programming the task on the cron, the script is executed but upon reaching the line of the POST request it generates the following error:

Traceback (most recent call last):
File "", line 241, in <module>
File "", line 41, in download_file
response =, data=json.dumps(args), headers=headers)
File "/usr/lib/python2.7/site-packages/requests/", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/", line 60, in 
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/", line 533, in 
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/site-packages/requests/", line 646, in 
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/", line 516, in 
raise ConnectionError(e, request=request)
HTTPSConnectionPool(host='', port=443): Max retries exceeded 
with url: /cloudV1/getFile (Caused by 
NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 
0x7f3652066390>: Failed to establish a new connection: [Errno -2] Name or 
service not known',))

Do I have to configure something in the cron to be able to execute the Python Requests module? What could be the cause?

The line that executes the task in cron is the following:

00 05 * * * python /home/scripts/generic/

0 Answers