How to make 404.html return 404 status code

Cloudflare Pages supports a fallback 404.html but the actual /404 path unexpectedly returns a 200. Is there a way to make sure that /404 itself also returns a 404?

Correctly returning a 404 for me, you sure it’s picking up your 404 file?

I am specifically talking about the /404 path, not any other path that doesn’t exist. for instance returns a 200.

Ha that’s pretty funny, I mean it makes sense I guess as you’re explicitly loading the 404 page rather than going to a 404. The 404 pages does exist.

Not sure what the behaviour should be here – technically what is happening now is correct.


Ha, this is fun, you got me curious. You can do it with a WAF rule, but only if you have a paid account; it won’t work on a free plan because you can’t use a custom HTML response on a free plan.

I tried this and pasted in my 404.html content as the custom response:

And it works!


I don’t completely agree that the behavior is “correct”, as the 404 behavior is already special-cased to begin with. There’s no particular reason why /404 shouldn’t also return a 404 (I can’t see why anyone would want it to return 200), or for the 404 page to actually be located in a path like .cloudflare/404.html where all files under .cloudflare don’t get served normally.