Troubleshooting · By Rivtor · Updated
Fix MCP Invalid Host Header after deployment
An MCP Invalid Host Header response can mean the SDK’s hostname protection still allows only local development hosts. Check the actual response and pinned SDK, then allow the intended production host explicitly. Do not remove hostname validation or authentication as a blanket fix.
See the Rivtor deployment workflow →
Confirm which layer rejected the request
Inspect the HTTP status and sanitized response body before changing the application. A 421 or explicit invalid-host response is different from a 404 route mismatch, a 401 authentication failure or a 502 upstream process error. Clients sometimes wrap those responses in a generic protocol exception.
Compare the endpoint URL in the client with the host and route your service is configured to accept. If you use a custom domain, confirm traffic actually reaches the expected application rather than an old service.
Check the installed SDK contract
The Python MCP SDK documents hostname checks that can accept localhost by default. A production hostname therefore needs deliberate configuration. Package APIs change across versions: use the configuration type supported by the installed SDK and keep the lockfile in the example project.
| Observation | Next investigation |
|---|---|
| Local works, production host rejected | Allowed host configuration |
| Public URL becomes plain HTTP | Proxy/TLS URL construction |
| Correct host but unknown route | Actual MCP endpoint path |
| Authentication error after host fix | Client credentials and server authorization |
Consult the official deployment reference and avoid copying parameters from an unrelated SDK release.
Configure a narrow trust boundary
Allow the hostname you intend to serve and the origin rules required by the application and client. Do not use a broad wildcard to make the error disappear. Do not trust arbitrary forwarded headers from untrusted callers. Hostname validation and authentication solve separate problems; preserving one does not replace the other.
For Rivtor, inspect the service hostname and any custom service configuration. The platform hostname must agree with the application’s accepted host rules. Keep this diagnosis separate from agent authentication against Rivtor’s own management MCP endpoint.
Recheck with a harmless tool
Reconnect the compatible client and invoke a read-only synthetic tool. Confirm the intended host succeeds and an unexpected host is still rejected in a controlled test environment. Record status, SDK version and sanitized error class. Do not expose token values, private tool arguments or customer data while collecting a reproduction.