Blog / Web management /
XML-RPC, the REST API and what to lock down on WordPress
Open the access log of almost any WordPress site and you’ll see the same visitor knocking again and again: a POST request to /xmlrpc.php. Hundreds of them, sometimes thousands, from addresses all over the world. Nobody on the team has ever used that file. Most don’t know it exists.
That’s the first of two doors into WordPress that site owners rarely think about. The second is the REST API at /wp-json/. Both are legitimate features. Both get abused. And both can be tightened without breaking your site, as long as you know what depends on them.
The short version: on most sites, XML-RPC can be switched off completely; the REST API should stay on, with a couple of things locked down. The rest of this post explains why, and how to check before you change anything.
XML-RPC: an old door that’s still open
XML-RPC is how remote tools talked to WordPress before the REST API existed. Old desktop blogging apps used it. The WordPress mobile apps used it. Some services still do, most famously Jetpack, which relies on it to connect your site to WordPress.com.
The problem is that it’s also an efficient way to attack a site:
- Password guessing. XML-RPC can accept many login attempts in a single request, so it gets around simple “limit login attempts” protection on the normal login page.
- Pingback abuse. The pingback feature can be used to make your site send requests to other sites, which attackers have used for denial-of-service traffic.
- Server load. Even failed attacks cost PHP and database work. On cheap shared hosting, a steady stream of XML-RPC requests can slow the real site down.
Should you switch it off?
Ask one question first: does anything on this site use it?
- Jetpack: yes, it needs XML-RPC. Leave it on, but protect it (more on that below).
- The WordPress mobile app: newer versions can use application passwords and the REST API, but older setups used XML-RPC. Check with whoever posts from a phone.
- Remote publishing or posting tools: some older integrations still use it. Check the list of services that post to the site.
If nothing does, switch it off.
How to switch it off
In order of preference:
- At the server or firewall. Block requests to
xmlrpc.phpbefore they ever reach WordPress. On Apache this is a few lines in.htaccess; on Nginx, alocationrule. If the site sits behind Cloudflare, a firewall rule that blocks the path does the same job at the edge, which is my favourite option because the requests never touch the server at all. (Cloudflare settings that help speed and security has more on that.) - With a security plugin. Most security plugins have a “disable XML-RPC” toggle. It works, but PHP still loads to reject each request, so it saves less server effort.
- With a filter in code.
add_filter( 'xmlrpc_enabled', '__return_false' );turns off the authenticated methods. It doesn’t stop every request from reaching the file, so I treat it as a backup rather than the main fix.
If you need to keep it for Jetpack, a firewall rule that allows only Jetpack’s own servers is the tidy middle ground. Jetpack publishes its IP ranges for exactly this.
The REST API: don’t switch it off
The REST API lives at /wp-json/ and it’s how modern WordPress works. The block editor uses it to save posts. Lots of plugins use it for forms, search, booking widgets and checkout features. WooCommerce uses it heavily.
I still see advice to “disable the REST API for security”. On a modern site, that breaks things, sometimes quietly. The editor stops saving, a form stops submitting, and nobody connects it to a security setting changed last month.
What’s worth locking down instead:
User enumeration
By default, /wp-json/wp/v2/users lists the authors on the site, including their usernames (the “slug”). That hands an attacker half of a login. On most business sites, there’s no reason for strangers to see it.
Most security plugins can restrict the users endpoint to logged-in users. Do that, and test that the author archive and anything else on the front end still work afterwards.
Unauthenticated access in general
Some plugins let you require a login for the REST API, except for routes that front-end features need. That’s a reasonable setting on brochure sites, but go carefully on shops and sites with public forms: you need to keep those routes open. Test the checkout and every form after any change.
Application passwords
Since WordPress 5.6, users can create application passwords for API access. They’re useful for integrations. They’re also a login that’s easy to forget about. Check each admin user’s profile now and then, and revoke any you don’t recognise. I keep that check in the quarterly access review from password managers and shared logins for client websites.
A safe order to make these changes
- Write down what’s connected. Jetpack, mobile app use, remote publishing, booking or form plugins, anything “talking” to the site.
- Take a backup and, where you have one, try the changes on staging first.
- Block XML-RPC if nothing on your list needs it.
- Restrict the users endpoint.
- Test the important journeys: edit and save a post, submit every form, run a test order.
- Log the change in the site’s change log, with the date. If something breaks in three weeks, you’ll want to see this entry first.
Does any of this affect SEO?
Not directly. Search engines don’t use XML-RPC or need the REST API to crawl your pages. But security problems quickly become SEO problems. A hacked site full of spam pages or a server so busy fighting bots that it slows to a crawl will cost you far more in search than any meta description ever will.
FAQ
Is XML-RPC still needed in 2024?
For most sites, no. Jetpack and a few older tools still need it. If you don’t use those, it’s safe to block.
Will disabling the REST API make my site more secure?
Slightly, at the cost of breaking the block editor and many plugins. Restricting the risky parts, like the users endpoint, gets you most of the benefit without the breakage.
Can I see whether bots are hitting xmlrpc.php?
Yes. Your hosting access logs will show requests to the file, and if you use Cloudflare, its security events show them too.
Related reading
- WordPress security basics every site owner should know
- WordPress security headers: a beginner’s guide
- Change logs for websites: why I write down every fix
Try this today: visit yoursite.com/wp-json/wp/v2/users in a private browser window. If you can read your usernames there, that’s your first thing to lock down.