votes up 1

Invalid URL %r: No host supplied

Exception Class:

Raise code

        if not scheme:
            error = ("Invalid URL {0!r}: No schema supplied. Perhaps you meant http://{0}?")
            error = error.format(to_native_string(url, 'utf8'))

            raise MissingSchema(error)

        if not host:
            raise InvalidURL("Invalid URL %r: No host supplied" % url)

        # In general, we want to try IDNA encoding the hostname if the string contains
        # non-ASCII characters. This allows users to automatically get the correct IDNA
        # behaviour. For strings containing only ASCII characters, we need to also verify
        # it doesn't start with a wildcard (*), before allowing the unencoded hostname.
        if not unicode_is_ascii(host):
😲 Agile task management is now easier than calling a taxi. #Tracklify

Ways to fix

votes up 0 votes down


The url passed to requests has a scheme but does not have a host. e.g http:///example/no/host does not have a host.


import requests
req = requests.Request('GET', 'https:///no/host/url') # No host 
r = req.prepare() 
s = requests.Session() 


import requests 
req = requests.Request('GET', '') # Host must be given
r= req.prepare()
s = requests.Session() 

Jun 01, 2021 cRyp70s answer
cRyp70s 113

Add a possible fix

Please authorize to post fix