The X-Powered-By header is a line a server adds to every response to announce what it runs, such as X-Powered-By: PHP/8.2.12, Express or Next.js. Visitors never see it, but scanners and attackers do, and it tells them which exploits to try first. If your site is behind Cloudflare you can remove the header at the edge without touching your server, and you can fix it at the origin as well.
This guide shows both ways, and uses the free Security Headers Checker to prove the header is gone.
First, confirm the header is there
- Open Security Headers Checker.
- Enter your site's address and press Scan headers.
- Find the row "Server / X-Powered-By" in Score breakdown. It carries 5 points. If the header is present, the result says "Leaks versions" and shows something like
X-Powered-By: PHP/8.2.12. - Scroll to All response headers and look for the
x-powered-byline. Header names are shown in lower case.
Note that the check flags X-Powered-By even when it has no version number, such as plain Next.js. It flags the Server header only when it contains a number. Also look in the same list for x-aspnet-version, x-aspnetmvc-version and x-generator, which the tool treats as leaks too.
Behind Cloudflare, the server header normally reads cloudflare, with no version. That is not flagged. Cloudflare's own documentation says the value of the server header cannot be changed, so there is nothing to do there.
Method 1: the managed transform
Cloudflare has a ready-made option for exactly this. In its list of Managed Transforms there is a response-header transform named "Remove "X-Powered-By" headers", which removes the header from your responses.
- Log in to the Cloudflare dashboard and choose your domain.
- Open the Rules section and look for Managed Transforms. Menu names change from time to time, so search the dashboard for "Managed Transforms" if you cannot see it.
- Switch on "Remove "X-Powered-By" headers".
This is the quickest way for most sites, and it covers every hostname on the zone that is proxied through Cloudflare.
Method 2: a Modify Response Header rule
Use a rule when you want more control, for example only on one hostname, or to remove other headers as well.
- In the dashboard open Rules, then Transform Rules, then Modify Response Header.
- Create a rule and give it a name such as "Remove X-Powered-By".
- Choose which requests it applies to: all incoming requests, or a custom expression such as one hostname.
- Under Modify header, choose the Remove operation and type the header name,
X-Powered-By. - Deploy the rule.
Cloudflare's documentation lists Set static, Set dynamic, Add static, Add dynamic and Remove as the operations. Our scan tool's generated Cloudflare note points to the same place (Rules, Transform Rules, Modify Response Header) and says to use Set static to add headers and Remove to delete them, so for a removal choose Remove, not Set.
If the scan flagged more than one header, add one Remove rule per header name, for example X-AspNet-Version or X-Generator. Cloudflare does not allow changes to headers beginning with cf- or x-cf-, but that does not affect these.
Method 3: fix it at the origin
Removing it at the edge hides it from visitors who come through Cloudflare. If the header is never sent in the first place, it is gone everywhere. The right switch depends on your stack:
| Stack | How to stop sending the header |
|---|---|
| Next.js | Set poweredByHeader: false in next.config.js |
| PHP | Set expose_php = Off in php.ini and restart PHP |
| Nginx with PHP-FPM | Add fastcgi_hide_header X-Powered-By; |
| Nginx as a proxy | Add proxy_hide_header X-Powered-By; |
| Apache | Add Header always unset X-Powered-By (needs mod_headers) |
| Express (Node) | Call app.disable('x-powered-by') |
The Security Headers Checker's Recommended headers panel writes some of these for you. Choose your Server platform, and set Which headers to Missing & weak. When a leak is found, the Nginx, Apache and Cloudflare output includes a removal line for each leaking header it found, such as X-AspNet-Version or X-Generator, not only X-Powered-By. The Next.js output turns off its own X-Powered-By and adds a comment for any other header, because Next.js does not send those itself; remove them at the server or proxy that adds them.
On Cloudflare Pages or Workers static assets, the generated output is a _headers file with a line ! X-Powered-By. Cloudflare's documentation says the ! detach only removes headers that earlier rules in the same file added, and that _headers does not apply to responses from Pages Functions. So if a header comes from your own Function code, remove it in the code.
Prove it worked
- Wait a minute, then scan again with the Security Headers Checker.
- The "Server / X-Powered-By" row should now say "No version leak" with 5 of 5 points.
- In All response headers,
x-powered-byshould be gone. - For a second opinion on the raw headers, the HTTP Header Checker lists the same set with caching and timing details.
The scan always goes through redirects to the final page, so make sure you enter the address visitors really use. A scan of example.com that redirects to www.example.com reads the headers of the www page.
If it is still there
- The record is DNS only. A grey cloud in Cloudflare's DNS list means traffic goes straight to your server and no Cloudflare rule runs. Look at the
serverheader in All response headers: if it does not saycloudflare, the response did not pass through Cloudflare. Switch the record to proxied, or fix the origin. - The rule does not match. If the rule is limited to one hostname, check that you scanned that hostname, and both the www and non-www forms.
- Another layer adds it. A load balancer, a second CDN or an application behind a reverse proxy may add the header after your origin. Remove it at the layer that sets it.
- An old cached copy. Purge the cache for the address once and scan again.
- You tested a page that is not served by your main site, such as a subdomain on a different host.
If the page will not load at all after your change, a status such as 521 or 522 is a connection problem, not a header problem. Those are explained in Cloudflare errors 520, 521 and 522.
Do not stop at one header
Removing X-Powered-By is a small win. The same scan will usually show bigger gaps: a missing Content-Security-Policy, a weak Strict-Transport-Security or cookies without flags. The complete Security Headers Checker guide shows how to work through them in order of points.
Quick checklist
- Scan first and note which leak headers appear.
- Turn on the managed transform, or add a Remove rule per header.
- Also stop the header at the origin.
- Scan again and confirm "No version leak".
- Remember that the
servervalue is Cloudflare's, and fine as it is.



