Error: httplib.py in_read_status raise BadStatusLine(line) BadStatusLine on ubuntu Error: httplib.py in_read_status raise BadStatusLine(line) BadStatusLine on ubuntu selenium selenium

Error: httplib.py in_read_status raise BadStatusLine(line) BadStatusLine on ubuntu


This error message...

File "/usr/lib/python2.7/httplib.py", line 402, in_read_status raise BadStatusLine(line) BadStatusLine

...implies that the BadStatusLine was raised as the server responded with a HTTP status code that we don’t understand.


httplib.BadStatusLine

exception httplib.BadStatusLine is defined in Python2.x - httplib / Python3.x - http.client module and is subclass of HTTPException which is raised if a server responds with a HTTP status code that we don’t understand.


Reasons and Solutions

There can be many reason behind seeing the httplib.BadStatusLine exception. As per Why am I getting this error in python ? (httplib) some of the pottential reasons and solutions are:

  • You may be trying to use http:// instead of https://
  • The URL string may be containing a trailing newline character. So make sure that your URL are stripped of any leading or trailing special characters.
  • The Web Server may be down and Not Responding.
  • The Server may be closing the connection before sending a valid response.
  • Presence of Content-Length within the http header can also create this exception.
  • If the time interval between two requests are more than he configured time of Keep-Alive timeout=n.
  • An easy solution would be to establish a new connection through conn.connect() before sending each request.