Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)'))

Question:

I am using requests python library to access an internal api –

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

But got this error message –
HTTPSConnectionPool(host='url', port=443): Max retries exceeded with url: '' (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)')))

I tried some of the other answer, but the issue is still there.
How to resolve the issue. What is the reason for the issue, as previously it was working fine.

Asked By: Gaurav

||

Answers:

I found the solution later.
I just edited the host entry in the server for the url to make the post request.

You can edit your host file at server/system –

vi /etc/hosts 

There I added, eg –

IP Url
0.0.0.0 google.com 
1.1.1.1 abc.com

This solves my error.

Answered By: Gaurav