close

[Solved] ValueError: check_hostname requires server_hostname

Hello Guys, How are you all? Hope You all Are Fine. Today I am running my proxy in request but it gives me the following error ValueError: check_hostname requires server_hostname in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ValueError: check_hostname requires server_hostname Error Occurs ?

I am running my proxy in request but it gives me the following error.


raise ValueError("check_hostname requires server_hostname")
ValueError: check_hostname requires server_hostname

Here is My Code

proxyArr ={
    'http':'http://my correct proxy here: myport',
    'https':'https://my correct proxy here: myport'
}
self.response=requests.get(url=url,headers=self.headers,proxies=proxyArr )

How To Solve ValueError: check_hostname requires server_hostname Error ?

  1. How To Solve ValueError: check_hostname requires server_hostname Error ?

    To Solve ValueError: check_hostname requires server_hostname Error In urllib3 version 1.25.11 working perfectly. So you can install urllib3 1.25.11 by following the command line. Actually urllib3 the main schema of proxy was changed and if you are using urllib3=1.26.4 then follow the below code. Just downgrade the urllib3 version by running this command. You can use pip install urllib3==1.25.8.

Solution 1: Use urllib3 1.25.11

In urllib3 version 1.25.11 working perfectly. So you can install urllib3 1.25.11 by following command line.

pip install urllib3==1.25.11

Solution 2: urllib3 the main schema changed

Actually urllib3 the main schema of proxy was changed and if you are using urllib3=1.26.4 then follow the below code.

Here is the old code before schema of proxy was changed

proxyArr ={
    'http':'http://my correct proxy here: myport',
    'https':'https://my correct proxy here: myport'
}
self.response=requests.get(url=url,headers=self.headers,proxies=proxyArr )

Here is the new code after the schema of proxy was changed.

proxyArr = {'https': 'http://8.88.888.8:8888'} 

self.response=requests.get(url=url,headers=self.headers,proxies=proxyArr )

Solution 3: Downgrade urllib3

Just downgrade urllib3 version by running this command.

You can use pip install urllib3==1.25.8

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also Read

Please Rate Our Solution to Motivate Us For Give Our Best

Leave a Comment