Skip to content

Block External Requests in WordPress localhost

I do some WordPress development on localhost and get frustrated when pages are not loading fast. Reason for slow pages on localhost is external requests.

Solution is to block all external requests in WordPress localhost (staging, development) environment. Pages load much faster and your main focus will be your project.

Watch on youtube.

Here is a video tutorial to block external requests in WordPress localhost / dev environment.

Block external requests for faster WordPress localhost development.

How to Block External Requests in WordPress?

Block external requests using plugin

Select "Block External Requests" for operation mode in plugin settings.

Blocking external requests with a plugin is an easy and preferred solution for beginners.

Here are step by step instructions to block external requests using a plugin.

  1. Install and activate “HTTP Requests Manager” Plugin from WordPress repository by navigating to “Plugins” → “Add new plugin” page and searching for “WP_HTTP”.
  2. Navigate to “Tools” → “HTTP Requests Manager” page.
  3. Click on the “Settings” tab.
  4. Choose “Block External Requests” for the “Operation mode” field. New setting will be saved automatically when you change it.
  5. Now all external requests will be blocked from your WordPress website.

Pros and cons

Pros:

Cons:

  • Additional plugin in your wordpress website.

Block external requests using config file

Block external requests using WordPress config file.

Blocking external requests in WordPress with a config file is for advanced users. But it is easy and effective.

Follow these steps:

  1. Navigate to the wordpress installation directory. Use File Explorer if you are on localhost. Use FTP or web control panel provided by your hosting if your development server on internet.
  2. Find a file called “wp-config.php”.
  3. Add following lines to “wp-config.php” file and save changes.

Use this code to block all external requests.

// Block all external requests
define('WP_HTTP_BLOCK_EXTERNAL', true);

If for some reason you want to allow requests to the WordPress repository then add these lines in addition to code above.

// allow requests to WordPress repository
define('WP_ACCESSIBLE_HOSTS', '*.wordpress.org');

Learn more from WordPress.org.

Pros and cons

Pros:

  • Simple and fast solution.
  • No need to use plugins. Faster development environment. Less files and less code.

Cons:

  • Can be risky to edit a config file when not done correctly.
  • After some time you will forget that you made some changes to the config file. You can forget and push this config file to the live environment. Or not recall why external requests are blocked after a long time.
  • Difficult to switch on/off.
  • Cannot view which requests are made or blocked.

FAQ

How much faster will localhost WordPress be when external requests are blocked?

Localhost WordPress will load in less than a second instead of 30 seconds when you block all external requests.

External requests blocked page loads in 1 second. Not blocked page loads in 30 seconds.

Look at the screenshot above to see how long the page takes to generate when external requests are not blocked. 30 seconds.

What type of WordPress development is done on localhost?

  • Developing WordPress plugin / theme. Need to make sure that it works with multiple WordPress versions (4,5,6 etc.) and multiple PHP versions (5.6, 7.x, 8.x etc.)
  • Updating content in bulk. 10-100 posts that need to be updated in a couple days.
  • Using it as a staging environment for trying new plugins before pushing to a live website.
  • Keep a local working copy of your live website as backup or ready to migrate to other web hosting.
  • Merge two different WordPress websites into a single one.

I use localhost for all of them.

Is it ok to block external requests on a live WordPress website?

No. WordPress will not work properly when you block all external requests. WordPress core uses external requests, also known as WP_HTTP requests for updates, adding plugins and themes.

Also some plugins use external requests for sending backups, loading statistics, loading extra features, creating payment buttons etc.

You may block external requests, at your own risk, only temporarily when doing updates in bulk on your live website. Updating more than 10 posts for example. For a couple hours at most.

What WordPress features will stop working when you block external requests?

Cannot add new plugin from WordPress repository when you block external requests.

WordPress core functionality that will not work without external requests:

  • All updates will be disabled.
  • New translations will not be loaded.
  • Cannot add new plugins or themes.
  • Cannot view plugin information inside your WordPress from the repository.

Some plugin features that will be disabled:

  • Cannot send backups (database, website files) to remote storage.
  • Cannot create payment buttons that are generated using API calls.
  • Cannot load analytics from google.
  • Cannot manage cache on CDN servers.
  • Cannot send emails using API calls.

Conclusion

Blocking external requests on localhost development WordPress websites is a timesaver. Pages will load under 1 second. You do not wait 30 seconds for the page to load and don’t get frustrated.

Development and working on localhost will be a much faster and pleasant experience. Which will help you complete your goals on time.

Using a plugin for blocking external requests is more convenient and easy for every user. Additionally it shows which external requests regularly happen on your WordPress website.

Learn more about HTTP Requests Manager plugin.

Leave a Reply

Your email address will not be published. Required fields are marked *