Backup and Security

How to Disable XML-RPC and Block REST API User Enumeration in WordPress

Block xmlrpc.php at the server, hide REST user routes from guests and stop ?author= probes. Code checked against WordPress core on 16 Nov 2026.

Varun DubeyVarun Dubey
·13 min read
Three terminal cards showing a 405 fault for xmlrpc.php, 404 for the REST users route and 404 for an author probe

To shut down XML-RPC properly, block xmlrpc.php at the web server or firewall. The popular one-line filter, add_filter( 'xmlrpc_enabled', '__return_false' ), only turns off the XML-RPC methods that need a login. WordPress core’s own documentation says the filter does not stop pingbacks or other methods that work without authentication. To stop REST API user enumeration, remove the users routes for logged-out visitors with the rest_endpoints filter and keep them for logged-in users, so the block editor still works. This guide gives you code checked against core for both, plus the ?author= redirect, application passwords and the curl checks that prove each block works. We checked every hook and claim below against the WordPress core source and official docs on 16 November 2026.

Nobody sent us search queries for this page yet, so we built the headings from the questions people type when they hit this problem: whether to disable XML-RPC at all, why the filter seems to do nothing, how to block the file without breaking Jetpack or the mobile app, and why a username list shows up at /wp-json/wp/v2/users. Skip to the section you need.

Should I disable XML-RPC on my WordPress site?

Yes, if nothing you use needs it. Disable it when you publish from the dashboard, use the REST API for integrations, and have no Jetpack connection or XML-RPC-based desktop publishing tool. Keep it, but restrict it, when Jetpack, the WordPress mobile apps or an older remote publishing client still depend on it.

XML-RPC is the older remote protocol that lives in xmlrpc.php in the site root. It predates the REST API, and WordPress ships it switched on. Two features make it worth a decision:

  • Authenticated methods. Methods such as wp.getUsersBlogs take a username and password. That makes the endpoint another place where someone can try passwords, separate from wp-login.php.
  • Batching. The server also exposes system.multicall, which lets one HTTP request carry many method calls. A login limiter that counts HTTP requests sees one request, while WordPress processes many attempts. WordPress core caps the size of a request through the xmlrpc_element_limit filter (30,000 elements by default), but that is a parser guard, not a login limiter.
  • Pingbacks. pingback.ping needs no login. When someone sends one, your server fetches the source URL they name. Pantheon’s security guide and several host knowledge bases list XML-RPC abuse, including brute-force attempts, as a reason they restrict the file.

Whether any of that matters to you depends on what else you run. A site with strong passwords, two-factor login and a firewall in front is not defenceless with XML-RPC on, but it is still carrying an endpoint it does not use. Removing unused surface is the cheapest hardening there is. For the wider picture, our five-minute WordPress security audit shows where this sits among the other checks.

Does the xmlrpc_enabled filter really disable XML-RPC?

No. It disables only the methods that require authentication. We read the current core source (wp-includes/class-wp-xmlrpc-server.php on the trunk branch, version 7.2 Beta 5 on the day we checked) and the filter’s own docblock says so directly: despite the name, it “only controls whether XML-RPC methods requiring authentication” are enabled, and it does not control whether pingbacks “or other custom endpoints that don’t require authentication” work.

The mechanics matter, because many guides, including an earlier version of this one, describe the filter as returning a 403 for everything. It does not. Core stores the filter result in a private flag and checks it inside the login() method. When the flag is false, a call that tries to log in gets an XML-RPC fault with code 405 and the text “XML-RPC services are disabled on this site.” The HTTP status of that response is still a normal reply, and the file is still executed by PHP on every request.

Three consequences follow:

  1. Brute-force calls through wp.getUsersBlogs fail at the login step, which is the part most people care about.
  2. pingback.ping and system.listMethods keep answering, because neither calls login(). You can see this yourself with the test in the curl section below.
  3. A curl check that expects an HTTP 403 will not pass with the filter alone. That 403 only appears when a server rule or firewall blocks the file before PHP runs.

If you want the filter’s behaviour plus pingbacks removed, use the xmlrpc_methods filter, which receives the full method list and lets you unset entries. Our companion write-up on the xmlrpc.php pingback route explains why this distinction is not just academic: a request that never needs a login can still reach code on your server when only the common filter is in place.

Layer

Blocks login-based methods

Blocks pingbacks

Stops PHP running

Jetpack and apps

xmlrpc_enabled filter

Yes (405 fault)

No

No

Stops working

xmlrpc_methods filter, unset chosen methods

Only those you remove

Yes, if you unset pingback.ping

No

Keeps working if you leave their methods

Apache or Nginx deny rule

Yes

Yes

Yes

Stops working

Firewall rule on the path

Yes

Yes

Yes

Stops, unless allowlisted

Allowlist (Jetpack ranges only)

For everyone else

For everyone else

For everyone else

Keeps working

Checked on 16 November 2026 against WordPress core trunk and the xmlrpc_enabled hook reference.

How do I block xmlrpc.php completely?

Deny the file in your web server configuration, which makes the request fail before PHP starts. This is the only option in the table that removes pingbacks and every other method at once and costs the server almost nothing per hit. Use the block that matches your server, then confirm with curl.

Apache and .htaccess

Apache 2.4 uses the Require directives. The older Order Deny,Allow form still appears in many tutorials and only works when the legacy compatibility module is loaded, so prefer this form. Put it above the WordPress rewrite block in .htaccess.

# Block XML-RPC (Apache 2.4+)
<Files "xmlrpc.php">
    Require all denied
</Files>

Nginx

In Nginx, an exact-match location returns the denial before the request reaches PHP-FPM. Reload the service after editing.

# Inside the server { } block of your site
location = /xmlrpc.php {
    deny all;
    access_log off;
    log_not_found off;
}

The two log lines are housekeeping. Scanners hit this path constantly, and without them every attempt writes a line to your access log.

Firewall or CDN rule

If a CDN or web application firewall sits in front of the site, a rule that blocks the request path /xmlrpc.php stops the traffic before it ever reaches your origin. In Cloudflare, that is a custom WAF rule with the action Block and an expression that matches the URI path. Hosts that run their own firewall, such as Pantheon, publish their own switch for this, so check your host’s knowledge base first because a duplicate rule at two layers is harder to debug later.

What if I need Jetpack or the mobile app?

Do not block it for everyone. Jetpack’s own support page states that Jetpack uses xmlrpc.php to communicate with WordPress.com and that if the file “is blocked for everyone, your Jetpack connection will stop working.” Their advice is to allow the file only from Jetpack’s published IP ranges, which they list as plain text at jetpack.com/ips-v4.txt and note can change, so do not copy the list into a config and forget it. A bare request to xmlrpc.php with no parameters is not genuine Jetpack traffic, whatever its user agent claims.

If you cannot use an IP allowlist, there is a middle path: keep the file reachable and remove only the dangerous methods with the xmlrpc_methods filter. The code below removes pingbacks and batching, and leaves the methods Jetpack and the apps use.

<?php
/**
 * Keep XML-RPC reachable for Jetpack and the apps,
 * but remove the methods most often abused.
 * File: /wp-content/mu-plugins/xmlrpc-trim.php
 */
defined( 'ABSPATH' ) || exit;

add_filter(
	'xmlrpc_methods',
	static function ( array $methods ): array {
		unset(
			$methods['pingback.ping'],
			$methods['pingback.extensions.getPingbacks'],
			$methods['system.multicall']
		);
		return $methods;
	}
);

We confirmed in core that pingback.ping and pingback.extensions.getPingbacks are registered in the method map and that system.multicall is registered by the underlying IXR server class, which is why unsetting those keys works. The code checks out as valid PHP 8.1 syntax (php -l, checked on 16 November 2026), but run it on a staging copy before it goes live, since a connected Jetpack site is the quickest way to find out whether your setup uses a method you just removed.

Be careful with plugin conflicts here. A security plugin that “disables XML-RPC” and a server rule that blocks it do the same job twice, and when Jetpack stops connecting, the cause is usually one of those two layers, not Jetpack. We cover the usual suspects in the common mistakes section further down.

What does the REST API users endpoint expose to visitors?

An unauthenticated visitor can request /wp-json/wp/v2/users and get back a JSON list of users, each with an ID, a display name, a profile link and a slug. The slug is derived from the account’s nicename, which on many sites matches the login name, so the response hands an attacker a confirmed username to try at the login form. We read the users controller in core trunk to see exactly who is listed.

The controller sets has_published_posts for any caller who lacks the list_users capability, using the post types that are visible in REST. So a logged-out request lists only accounts that have published at least one public post. An administrator with no posts, a subscriber, a shop customer: none of those appear. That is useful to know, because it narrows the exposure from “every user” to “every author”, which on most blogs is still the people you least want guessed.

A few details people get wrong:

  • Single-user routes follow the same rule. Core only returns /wp/v2/users/<id> to a logged-out caller if that user has published posts, and returns rest_user_cannot_view otherwise.
  • Asking for the edit context, or filtering by roles or capabilities, needs list_users and returns an error for visitors.
  • The slug is not guaranteed to equal the login. If an administrator changed the nicename, the leaked value is harmless for login guessing. Do not rely on that: you cannot tell which accounts changed it.

Exposure through REST is only one of several routes. Core also publishes authors through the users sitemap, oEmbed responses and author archive URLs. We tested all five on a live install in Every Way Your WordPress Site Hands Out Usernames, which is the right companion read if you want the full list. This guide stays on the REST route and the numeric author redirect because those are the two the title promises.

How do I block REST API user enumeration without breaking the editor?

Remove the users routes for logged-out visitors with the rest_endpoints filter, and leave them in place for logged-in users. The block editor loads author data from these routes, so a blanket block, or a block that returns a 404 to everyone, breaks the author selector. Core runs this filter when it builds the route table, and the callback below keeps anything that does not start with the users prefix.

<?php
/**
 * Hide the /wp/v2/users routes from logged-out visitors.
 * File: /wp-content/mu-plugins/rest-users-private.php
 */
defined( 'ABSPATH' ) || exit;

add_filter(
	'rest_endpoints',
	static function ( array $endpoints ): array {
		if ( is_user_logged_in() ) {
			return $endpoints;
		}

		foreach ( array_keys( $endpoints ) as $route ) {
			if ( 0 === strpos( $route, '/wp/v2/users' ) ) {
				unset( $endpoints[ $route ] );
			}
		}

		return $endpoints;
	}
);

A logged-out request to the users route now gets the standard “no route” error with HTTP 404, and the route disappears from the /wp-json/wp/v2 discovery document too. This also covers the single-user routes and /wp/v2/users/me, because the loop matches the prefix.

Prefer a 401 instead of a 404?

Some teams want a clear “authentication required” answer for clients that retry on 401. The rest_authentication_errors filter is the documented place to reject requests. It does not receive the route, so you read it from the global request. This version also allows through anything that is not the users route.

<?php
/**
 * Return 401 for logged-out requests to the users routes.
 * File: /wp-content/mu-plugins/rest-users-401.php
 */
defined( 'ABSPATH' ) || exit;

add_filter(
	'rest_authentication_errors',
	static function ( $result ) {
		if ( ! empty( $result ) || is_user_logged_in() ) {
			return $result;
		}

		$route = isset( $GLOBALS['wp']->query_vars['rest_route'] )
			? (string) $GLOBALS['wp']->query_vars['rest_route']
			: '';

		if ( 0 === strpos( $route, '/wp/v2/users' ) ) {
			return new WP_Error(
				'rest_not_logged_in',
				__( 'Sign in to view users.', 'default' ),
				array( 'status' => 401 )
			);
		}

		return $result;
	}
);

Pick one of the two. Running both is harmless but pointless, because the route is already gone by the time the authentication filter would run.

When you should not block it

Do not use either snippet if a headless front end, a mobile app or a third-party service reads public author names from this route without logging in. A support thread on WordPress.org describes a mobile shop app that stopped fetching data after a security plugin blocked the users route and returned the “not allowed to list users” 401. If you need author data publicly, serve it from a route you control and expose only the fields you intend to publish, such as a display name and avatar, never the slug.

Does the ?author=1 redirect leak usernames?

Yes, when the account has at least one published post. Core’s canonical redirect code takes a numeric author query value, looks up the user, checks that the user has a published post, and then redirects to the pretty author URL, which contains the nicename. Bots can walk IDs 1, 2, 3 and collect every redirect target without touching the REST API.

The redirect runs on the template_redirect action at its default priority, so a callback registered at priority 1 runs first. The version below only reacts to a plain numeric value, which is the form scanners use, and it ends the request with a 404 before core builds the redirect.

<?php
/**
 * Stop numeric ?author= probes from redirecting to /author/name/.
 * File: /wp-content/mu-plugins/author-probe-block.php
 */
defined( 'ABSPATH' ) || exit;

add_action(
	'template_redirect',
	static function (): void {
		if ( is_user_logged_in() ) {
			return;
		}

		if ( isset( $_GET['author'] ) && is_string( $_GET['author'] ) && ctype_digit( $_GET['author'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
			wp_die(
				esc_html__( 'Not found.', 'default' ),
				esc_html__( 'Not found', 'default' ),
				array( 'response' => 404 )
			);
		}
	},
	1
);

Visitors can still open /author/name/ archive pages normally, because those do not use the query parameter. If you do not publish author archives at all, the better fix is to turn them off in your SEO plugin or theme. The redirect is also easy to block at the server, which saves a PHP boot per probe:

# Nginx: inside the server { } block, not inside another location
if ( $arg_author ~ "^[0-9]+$" ) {
    return 404;
}

The $arg_author variable is Nginx’s built-in access to a query argument. Nginx documentation warns that if inside a location block has odd edge cases, which is why we place it at server level. Apache sites can get the same result with a RewriteCond %{QUERY_STRING} ^author=[0-9]+$ followed by a RewriteRule ^ - [R=404,L] above the WordPress rules.

Should I turn off application passwords too?

Only if nothing uses them. Application passwords let an external tool authenticate to the REST API as a user, and they are on by default over HTTPS. They are not an enumeration route, but they are another credential surface, and an unused credential type is something you can remove. Check first, then switch it off.

# Does any user have an application password? (checked 16 Nov 2026)
for id in $(wp user list --field=ID); do
  n=$(wp user application-password list "$id" --format=count)
  [ "$n" -gt 0 ] && echo "User $id has $n application password(s)"
done

The WP-CLI command takes a user ID, login or email, and supports --format=count, according to the WP-CLI handbook entry. If the loop prints nothing, add the filter documented as wp_is_application_passwords_available:

<?php
add_filter( 'wp_is_application_passwords_available', '__return_false' );

Existing application passwords stop being accepted once the filter returns false, and the profile section disappears. If a deployment script or a mobile publishing workflow relies on one, you will find out the moment you ship this, so keep the check above in your release notes.

How do I prove each block works?

Test with curl and no cookies. A browser carries your login cookie, so your own test shows the logged-in view, where the users route correctly still works. These checks use yoursite.example as a placeholder.

# 1. Filter-only setup: login methods fail, but the method list still answers
curl -s -X POST https://yoursite.example/xmlrpc.php \
  -H "Content-Type: text/xml" \
  -d '<?xml version="1.0"?><methodCall><methodName>system.listMethods</methodName></methodCall>' | head -c 400
# With only xmlrpc_enabled false you still see a list that includes pingback.ping.

# 2. Server-level block: expect 403
curl -s -o /dev/null -w "%{http_code}\n" https://yoursite.example/xmlrpc.php

# 3. REST users route, logged out: expect 404 (rest_endpoints) or 401 (auth filter)
curl -s -o /dev/null -w "%{http_code}\n" https://yoursite.example/wp-json/wp/v2/users

# 4. Author probe: expect 404, and no Location header
curl -sI "https://yoursite.example/?author=1" | grep -iE "^HTTP|^location"

Read the first test carefully. If it lists methods when you expected a block, that is the filter-versus-server difference from earlier, not a bug in your setup. For the server rule in test 2, a 405 or 200 means the deny line was not saved or the service was not reloaded. Managed hosts that ignore .htaccess will fail this test, and for those the answer is the host’s own firewall setting.

If you have WP-CLI on the server, two quick checks avoid an HTTP round trip:

# Is the xmlrpc_enabled filter returning false?
wp eval 'echo apply_filters( "xmlrpc_enabled", true ) ? "ENABLED" : "DISABLED";'

# Are your must-use files loaded?
wp plugin list --status=must-use

The --status=must-use option is listed in the plugin list command reference. If the first command prints ENABLED while your mu-plugin sits in the folder, check the file name ends in .php and sits directly in mu-plugins, not in a subfolder. WordPress does not scan subfolders of that directory.

Can I put it all in one must-use plugin?

Yes, and for a single site it is the tidy option. Must-use files load before normal plugins and cannot be switched off from the Plugins screen. We compared where snippets should live in Your WordPress Snippets Are Not in Your Deploy, and the short version is that a file in version control survives restores and staging syncs, while a snippet kept in the database does not. This file combines the filter pieces from above. It does not replace the server-level block, which still does the heavy lifting.

<?php
/**
 * Plugin Name: Login Surface Hardening
 * Description: Trims XML-RPC, hides REST user routes from visitors, blocks numeric author probes.
 * Version: 2.0.0
 */
defined( 'ABSPATH' ) || exit;

// 1. Login-based XML-RPC methods off; remove pingbacks and batching.
add_filter( 'xmlrpc_enabled', '__return_false' );
add_filter(
	'xmlrpc_methods',
	static function ( array $methods ): array {
		unset(
			$methods['pingback.ping'],
			$methods['pingback.extensions.getPingbacks'],
			$methods['system.multicall']
		);
		return $methods;
	}
);

// 2. REST users routes: gone for logged-out visitors.
add_filter(
	'rest_endpoints',
	static function ( array $endpoints ): array {
		if ( is_user_logged_in() ) {
			return $endpoints;
		}
		foreach ( array_keys( $endpoints ) as $route ) {
			if ( 0 === strpos( $route, '/wp/v2/users' ) ) {
				unset( $endpoints[ $route ] );
			}
		}
		return $endpoints;
	}
);

// 3. Numeric ?author= probes end in a 404, before the canonical redirect.
add_action(
	'template_redirect',
	static function (): void {
		if ( is_user_logged_in() ) {
			return;
		}
		if ( isset( $_GET['author'] ) && is_string( $_GET['author'] ) && ctype_digit( $_GET['author'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
			wp_die(
				esc_html__( 'Not found.', 'default' ),
				esc_html__( 'Not found', 'default' ),
				array( 'response' => 404 )
			);
		}
	},
	1
);

With xmlrpc_enabled returning false, Jetpack and the mobile apps stop being able to log in over XML-RPC, so drop that first line if you rely on them and keep the xmlrpc_methods trim instead.

Common mistakes people report

These are the problems that recur in support threads and vendor guides. Each link was open when we checked on 16 November 2026.

  1. A server or host rule blocks XML-RPC and the mobile app fails. A WordPress mobile app thread traced a 403 on the iPad app to a hosting security rule that intermittently blocked POST requests to xmlrpc.php, not to WordPress or Wordfence. Support’s reply there was that the apps still rely on XML-RPC and there is no public removal timeline.
  2. Blocking the file for everyone breaks Jetpack. Jetpack’s support page says a block for everyone stops the connection and recommends allowing only Jetpack’s ranges. Re-check the list from their source instead of pasting an old copy.
  3. Believing the filter closed pingbacks. It did not. The core source documents that the filter covers methods needing authentication only. Use a server rule or xmlrpc_methods for the rest.
  4. Blocking the users route for everyone, including admins. Plugins that return 401 or 404 to logged-in users empty the block editor’s author selector. A WordPress.org thread shows an app breaking on the same 401 when a security plugin guarded the route. Check for logged-out requests only, as the filters above do.
  5. Testing while logged in. Your browser’s login cookie means the users route works for you even after the block. Use curl with no cookies, or a private window that has never logged in.
  6. Two layers that fight. A security plugin toggle, a host firewall rule and a hand-written deny rule can all block the same file. When something breaks, disable them one at a time and test after each.

Frequently asked questions

Is it safe to delete xmlrpc.php?

Do not delete it. A core update puts the file back, and a missing file is no safer than a blocked one. Block the path in the server so the file stays in place and updates do not fight you.

Will disabling XML-RPC hurt SEO?

No. Search engines do not read the endpoint. The only visible effect is that pingbacks and trackbacks from other blogs stop, which most sites already moderate away.

Does the WordPress mobile app still need XML-RPC?

Parts of it still do. The thread in the mistakes list above shows support confirming that the apps rely on it for some flows. Test your actual publishing workflow on staging before blocking the file on a site you publish to from a phone.

Does blocking the users route hide author names on my blog?

No. Post bylines and author archive pages are rendered by your theme and keep working. You only close the machine-readable list that bots read.

Is hiding usernames enough to protect a login?

No, it only raises the effort. Treat it as one layer: add two-factor login, rate limit attempts and use unique strong passwords. Our guides on login security and brute-force protection cover those.

What PHP version do these snippets need?

They use closures, typed returns and static function, which work on PHP 8.1 and later. We linted each block with php -l on 16 November 2026. WordPress.org currently recommends PHP 8.3 or higher.

What to do next

Block xmlrpc.php at the server (or allowlist Jetpack if you use it), drop in the REST users and author filters, then run the four curl checks. Keep the files in version control so a restore does not silently undo them. If you have never audited the rest of the site, start with the five-minute audit linked above.

Part of the Wbcom Designs family

The all-in-one WordPress community stack

Also ours: wbcomdesigns.comvapvarun.combrndle.com