# ERROR: Invalid value for '--trusted-host': 'example.com:8080' does not match expected pattern. Expected a hostname or IP address, optionally with a port.

- **ID:** `pip/trusted-host-flag-misuse`
- **Domain:** pip
- **Category:** config_error
- **Error Code:** `ERROR`
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

The --trusted-host flag was passed a value with an incorrect format, such as a URL with scheme (https://...) or an invalid port separator, which pip cannot parse for its trusted host logic.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| pip 23.3 | active | — | — |
| pip 24.0 | active | — | — |
| pip 24.1 | active | — | — |

## Workarounds

1. **Use the correct format: --trusted-host example.com:8080 (no scheme, no trailing slash)** (95% success)
   ```
   Use the correct format: --trusted-host example.com:8080 (no scheme, no trailing slash)
   ```
2. **If using a config file, set trusted-host = example.com:8080 in pip.conf or pip.ini** (90% success)
   ```
   If using a config file, set trusted-host = example.com:8080 in pip.conf or pip.ini
   ```
3. **For multiple hosts, repeat the flag: --trusted-host host1 --trusted-host host2:443** (85% success)
   ```
   For multiple hosts, repeat the flag: --trusted-host host1 --trusted-host host2:443
   ```

## Dead Ends

- **** — Pip expects only hostname:port, not a full URL; the scheme is implied. (80% fail)
- **** — The parser strictly expects a hostname without path components. (60% fail)
