[Solved] Python requests ConnectionError Error: connection aborted BadStatusLine

Error Messages:

raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: (‘Connection aborted.’, BadStatusLine(“””, ))
Codes

data = {"host":host,"key":key,"value":value,"dns":ip} 

res = requests.post(url=url,json = data)

Method 1: add retry

requests.adapters.DEFAULT_RETRIES = 5

Method 2: add header

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.0; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0'} 

res = requests.post(url=url,json = data,headers=headers)

Method 3: curl
If method 1,2 does not work, use curl command to find the following error messages:
Empty reply from server

Solution: https://stackoverflow.com/questions/48814200/connection-aborted-badstatusline-on-server

Read More: