Search code examples
pythonpython-2.7sslurllibhttplib

"getaddr info failed" Error When Attempting POST


I am using urllib and httplib to do an HTTPS POST to a web page, using a PEM cert file and key fileWhen I ran it I got the following error: "I/O error (10109): getaddrinfo failed"

It is obvious I am getting the error trying to do the POST request. How do I eliminate this error?


Solution

  • You've used an incorrect syntax for the hostname and port number. Instead of:

    HTTPSConnection("avaa2.example.mil:443", ...)
    

    Try this:

    HTTPSConnection("avaa2.example.mil", 443, ...)
    

    Reference: https://docs.python.org/2/library/httplib.html#httplib.HTTPSConnection