How to Block Outbound Requests From a WordPress Server
Block outbound requests from a WordPress server with WP_HTTP_BLOCK_EXTERNAL, an allowlist and a host egress rule, so exploits cannot fetch their payloads.
To block outbound requests from a WordPress server, define WP_HTTP_BLOCK_EXTERNAL in wp-config.php, list the hosts the site genuinely needs in WP_ACCESSIBLE_HOSTS, and back both with an egress rule on the host or network firewall. The WordPress constants stop the WordPress HTTP API from reaching unknown hosts. The firewall catches code that bypasses that API. Together they remove the step most plugin exploits rely on: making your server download the attacker's payload.
Why does a web server need to make outbound requests at all?
A WordPress server contacts the internet to check for core, plugin and theme updates, to validate premium plugin licenses, to send mail through an API, to talk to payment gateways and to purge CDN caches. Those destinations are a short, stable list for any given site. Everything outside that list is either a misconfiguration or an attack.
What does WP_HTTP_BLOCK_EXTERNAL do?
WP_HTTP_BLOCK_EXTERNAL is a wp-config.php constant that, when set to true, makes the WordPress HTTP API refuse requests to any host other than localhost and the site itself. The companion constant WP_ACCESSIBLE_HOSTS takes a comma-separated list of hostnames that remain allowed, and wildcard entries such as *.wordpress.org cover whole domains. Both are documented in the WordPress developer reference for wp-config.php.
Why this matters after the WP Rocket exploit
The November 2026 campaign against WP Rocket sites worked in two steps. A crafted request to a public AJAX endpoint made the plugin accept an attacker-supplied URL. The server then fetched content from that URL and saved it as a PHP file. Patchstack's detection guidance for CVE-2026-125812 included watching for outbound connections from the web server to unfamiliar hosts, nip.io names and trycloudflare.com tunnels. Those are precisely the connections an egress allowlist refuses.
An allowlist does not fix the vulnerable code. It changes the outcome from remote code execution to a failed fetch and a log line. For a bug you have not heard of yet, that difference is the whole game.
Step 1: Inventory the destinations the site needs
Build the list before you block anything, or the first thing you break will be updates. Typical entries:
- api.wordpress.org and downloads.wordpress.org for core, plugin and theme updates from the WordPress.org repository
- The license and update servers of each premium plugin and theme. WP Rocket's documentation, for example, describes cloud features such as Remove Unused CSS that run as an external service, and its update check needs to reach WP Media
- fonts.googleapis.com and fonts.gstatic.com if a plugin self-hosts Google Fonts, since it must download them once
- Your transactional mail provider's API
- Payment gateway endpoints
- CDN and cache-purge APIs
- Monitoring, backup and security services that phone home
Get the hostnames from each vendor's documentation or from a week of outbound connection logs on a staging copy. Do not guess, and do not add a bare wildcard to make an error go away.
Step 2: Add the constants to wp-config.php
Place these lines in wp-config.php above the line that tells you to stop editing. The example comes from the WordPress developer documentation; replace the host list with your inventory:
define( 'WP_HTTP_BLOCK_EXTERNAL', true );
define( 'WP_ACCESSIBLE_HOSTS', 'api.wordpress.org,*.github.com' );
Wildcards apply to subdomains, so *.wordpress.org allows every host under wordpress.org. Keep the list specific. Every wildcard is a domain an attacker could register a subdomain on, or compromise, to host a payload.
Step 3: Test every feature that leaves the server
After saving, exercise the paths that make outbound calls: run a plugin update check, trigger a license re-validation, send a test email, place a test order in a sandbox, purge the CDN. A blocked call fails inside WordPress rather than at the network layer, so the symptoms are application errors such as a plugin reporting that its license cannot be verified or the updates screen showing nothing new. Add the missing host and retest. Expect two or three rounds on a site with many plugins.
Document the final list next to the site's other configuration. The next person who sees a license error needs to know why.
Step 4: Add a firewall egress rule
The WordPress constants only govern code that uses the WordPress HTTP API. PHP code can open remote URLs directly through cURL or PHP's stream wrappers, and a web shell dropped by an earlier compromise ignores WordPress entirely. The firewall is what covers those cases.
The rule is the same idea at a lower layer: the web server process, or the whole host, may open outbound connections only to the destinations on your inventory, plus DNS and your package mirrors. Everything else is denied and logged. On a single server this is a host firewall policy; in a cloud account it is the security group or network ACL attached to the instance; behind a corporate perimeter it is an egress rule on the next-hop firewall. The exact syntax depends on your platform, so take it from your firewall's own documentation and test it the same way as Step 3. If your hosting plan gives you no control over outbound traffic, note that as a gap and raise it with the host.
Destination filtering by hostname is harder at the firewall than in WordPress, because the firewall sees IP addresses. Vendors that publish IP ranges make this easy. For those that do not, a forward proxy that applies hostname rules and logs every request is the usual answer on servers that handle payments or sensitive data.
Step 5: Alert on blocked attempts
A blocked outbound connection from a web server is high-signal. Legitimate traffic was allowlisted in Step 1, so a denial means either a new plugin feature you have not inventoried or an exploit that got as far as trying to fetch something. Route the firewall's deny log for the web server to whatever already pages someone, and treat a burst of denials to a bare IP address, a nip.io name or a trycloudflare.com host as a live incident rather than noise.
Limits to keep in mind
Egress filtering does not stop attacks that carry the whole payload in the inbound request, and it does not stop data leaving through the responses to normal web requests. It also adds friction every time someone installs a plugin that calls a new service, and that friction is the point: a new outbound destination is a change that deserves a decision. Pair it with an inventory of the site's public AJAX actions, since admin-ajax.php is the usual front door, and with a license policy that keeps every premium plugin receiving updates. An allowlist buys time; the patch still has to land.