Cloudflare Error 1040 / 1041: Invalid request header modification
A Transform Rule tried to set or remove a request header that Cloudflare doesn’t allow to be modified, or produced an invalid value.
Seen on:
Cloudflare
Meaning
Some headers (Host, Content-Length, cf-* headers) can’t be modified with Transform Rules, and values must be valid header text.
Common causes
- Modifying a reserved header (Host, cf-connecting-ip, etc.)
- Invalid characters in the new header value
- Dynamic expression evaluating to an invalid value
⚡ Quick fix
- Remove the modification of reserved headers
- Use Origin Rules for Host header overrides
- Validate the header value expression
Detailed fix by platform
Cloudflare
# Rules → Origin Rules → Host Header override (instead of a request header Transform Rule)
How to diagnose
- Header — Which header is modified?
- Value — Valid characters?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Cloudflare
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026