Skip to content

Protocol fallback sends HTTP to HTTPS port (443) causing 400 errors #2335

Closed

Description

@ehsandeep

httpx version:

latest

Current Behavior:

When httpx falls back from HTTPS to HTTP on targets with explicit port 443, it keeps the same port, causing 400 The plain HTTP request was sent to HTTPS port errors, i.e resulted as valid / open host but it's actually not.

Expected Behavior:

Before:

$ echo "1.117.60.202:443" | httpx -probe
http://1.117.60.202:443 [FAILED]  # 400 error - HTTP to HTTPS port

After:

$ echo "1.117.60.202:443" | httpx -probe
http://1.117.60.202:80 [SUCCESS]  # Falls back to correct port

Steps To Reproduce:

echo 1.117.60.202:443 | httpx -silent -title
http://1.117.60.202:443 [400 The plain HTTP request was sent to HTTPS port]

Activity

  1. self-assigned this
    on Dec 6, 2025
  2. added theissue type on Dec 6, 2025
  3. added
    Type: Bug
    on Dec 6, 2025
  4. ehsandeep commented on Dec 8, 2025

    @ehsandeep
    MemberAuthor

    Fixed in afd5951

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type: Bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions