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.

  1. Go to Settings → Adminkeep.
  2. 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:

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>'
server error. requested method wp.getUsersBlogs does not exist.

What it does not do

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.

Switch on what you need. Forget the rest.

A free WordPress plugin — GPL, instantly reversible, and updates come to you.

Type to search the whole site.