How to disable XML-RPC in WordPress
Published View as Markdown
How to disable XML-RPC in WordPress three ways: a one-line filter, a web server rule, or a switch in the dashboard. Plus how to check that xmlrpc.php is closed.
XML-RPC is WordPress’s old remote API, at /xmlrpc.php. Most sites have no use for it, and bots send it password guesses all day.
Here is how to disable XML-RPC in WordPress, three ways, and how to check it worked. Not sure you should? Read Should you disable XML-RPC in WordPress? first. In short: leave it on if you use the Jetpack mobile app or a legacy remote publishing tool.
The xmlrpc_enabled filter: only half
The snippet most articles give:
add_filter( 'xmlrpc_enabled', '__return_false' );
It refuses only the methods that log in. A password guess gets fault 405:
XML-RPC services are disabled on this site.
Methods that need no login, pingbacks among them, still answer.
Block xmlrpc.php at the web server
Nginx:
location = /xmlrpc.php {
deny all;
}
Apache 2.4, in .htaccess:
<Files xmlrpc.php>
Require all denied
</Files>
The server answers 403 before WordPress loads. This is the complete version, and it needs access to the server configuration.
Disable XML-RPC with a switch
Adminkeep is a free plugin of small features with one switch each. One of them closes XML-RPC from the dashboard.
- Go to Settings → Adminkeep.
- Switch on Disable XML-RPC. There is nothing else to set.
From WP-CLI:
wp adminkeep feature enable disable_xmlrpc
While the switch is on:
- Every WordPress method is removed. That covers the login methods bots guess passwords through, and
pingback.ping. - Pingbacks and trackbacks are closed on every post.
- The site stops advertising the endpoint. The
X-Pingbackheader and the RSD link in the page head are gone.
Nothing is written to the database. Switch it off and XML-RPC is back at once. The configuration docs list every feature.
Check that it worked
Ask the endpoint what it offers:
curl -s https://example.com/xmlrpc.php -H 'Content-Type: text/xml' \
-d '<?xml version="1.0"?><methodCall><methodName>system.listMethods</methodName><params></params></methodCall>'
- Not disabled: a long list of
wp.,metaWeblog.andmt.methods. - Filter only: the same long list. The filter shows only when a login is tried, as fault 405.
- Server rule: a 403 page.
- Adminkeep switch: three methods are left,
system.multicall,system.listMethodsandsystem.getCapabilities. They belong to the XML-RPC library and reach nothing in WordPress. A login attempt gets:
server error. requested method wp.getUsersBlogs does not exist.
What it does not do
- Bots keep asking. With the filter or the switch, WordPress still loads and answers each request. Only the server rule turns them away first.
- The login form is still there. Password guessing moves to
wp-login.php. Two-factor authentication by email covers that. - The REST API is untouched. It is a separate API at
/wp-json/.
Questions people ask
How do I disable XML-RPC in WordPress?
Block xmlrpc.php in your web server configuration, or remove its methods from inside WordPress with a plugin switch. The one-line xmlrpc_enabled filter only refuses the methods that need a login.
How do I check if XML-RPC is enabled?
Send a POST request to /xmlrpc.php that calls system.listMethods. A long list of wp. and metaWeblog. methods means it is on. Opening the file in a browser only shows "XML-RPC server accepts POST requests only.", which says the file is there, not whether it is disabled.
Can I disable XML-RPC without a plugin?
Yes. Add a rule for xmlrpc.php to your Nginx configuration or your .htaccess file. The server then answers 403 before WordPress loads.
Does disabling XML-RPC affect the REST API?
No. The REST API is a separate API at /wp-json/. The block editor uses it, and none of the methods here touch it.