1037: Invalid Rewrite Rule: Failed to Evaluate ExpressionError 1037 means that a Transform Rule's rewrite expression failed to evaluate when processing a specific request. The rule's expression syntax may be valid (it passed validation when saved) but it encounters a runtime error when applied to the actual request — such as a type mismatch, division by zero, or accessing a property that does not exist in the current request context.
Error 1037: Invalid Rewrite Rule: Failed to Evaluate ExpressionGET /content/page HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0
Accept: text/htmlHTTP/1.1 409 Conflict
Server: cloudflare
CF-RAY: 7a7b8c9d0e1f2346-RIX
Content-Type: text/html
<!doctype html>
<html>
<head>
<title>www.example.com | Error 1037</title>
</head>
<body>
<h1>Error 1037: Invalid rewrite rule: failed to evaluate expression</h1>
<p>A Cloudflare Transform Rule expression failed to evaluate for this request. Please contact the site owner.</p>
</body>
</html>In Rules > Transform Rules, review each rule's expression. Test with the specific request URL that triggers the error.
Verify that all fields used in the expression are available for your Cloudflare plan. Some fields (like cookies, bot score) require specific plan levels.
Wrap field accesses in conditional checks to handle cases where a field may not be present. Use the 'not' operator or default values where possible.
The expression uses fields like http.request.cookies or ip.geoip.subdivision that are not available for all requests or plan levels.
The expression tries to perform an operation on incompatible types — like string concatenation with a number or comparing different types without conversion.
A regex_replace() or other string function encounters an input pattern it cannot handle, causing a runtime evaluation failure.
A Cloudflare Transform Rule or rewrite produced an invalid URI path.
A Cloudflare Transform Rule produced a URL that exceeds the maximum allowed length.
A Transform Rule attempted to modify a request header that Cloudflare does not allow to be changed.
This reference was compiled from official RFCs, protocol specifications, and hands-on troubleshooting experience. AI tools were used primarily for formatting and organizing the content on the page.