shaare.it

Malformed HTTPS URL

7 Dec 2025

1 min read

Malformed HTTPS URL

$ python -c "import requests; requests.get('https:/example.com')"
Traceback (most recent call last):
  ...
requests.exceptions.InvalidURL: Invalid URL 'https:/example.com': No host supplied

Why this happens

Missing slashes, bad ports, or https used with http servers lead to SSL handshake errors or invalid URL parsing.

Fix

Ensure proper URL format: https://host/path. Verify server supports TLS on the chosen port.

Wrong code

import requests
requests.get('https:/example.com')

Fixed code

import requests
requests.get('https://example.com', timeout=10)