Title: HTTP_HOST in local environment WP-CLI
Last modified: May 5, 2023

---

# HTTP_HOST in local environment WP-CLI

 *  Resolved [p15h](https://wordpress.org/support/users/prestonwordsworth/)
 * (@prestonwordsworth)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/http_host-in-local-environment-wp-cli/)
 *     ```wp-block-code
       PHP Warning:  Undefined array key "HTTP_HOST" in /home/www/htdocs/wp-content/plugins/wp-cloudflare-page-cache/libs/html_cache.class.php on line 79
       Warning: Undefined array key "HTTP_HOST" in /home/www/htdocs/wp-content/plugins/wp-cloudflare-page-cache/libs/html_cache.class.php on line 79
       ```
   
 * Dear Majumder
 * This issue seems to be prevalent across a host of plugins. From what I’ve read,
   the fix seems to be relatively straightforward: see [here](https://wordpress.org/support/topic/php-warning-undefined-array-key-http_host/)
   and [here](https://wordpress.org/support/topic/undefined-index-http_host-in-local-environment-wp-cli/).
   Could we use a solution similar to what’s proposed in the second link `if(!isset(
   $_SERVER['HTTPS'])) return;` ?
 * FYI, our own use case for WP CLI is in a setup using Linux’s crontab in place
   of WP Cron to run cron jobs including those for this plugin.

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Contributor [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/http_host-in-local-environment-wp-cli/#post-16719401)
 * Hi [@prestonwordsworth](https://wordpress.org/support/users/prestonwordsworth/),
   
   I totally understand why you opened this thread, but it is not that easy to implement
   here as `HTTP_HOST` is used in both the `advanced-cache.php` and `html_cache`
   system. Returning from there when does not exist will cause many issues as the
   plugin is highly dependent on those values.
 * This is why we can’t just look elsewhere when it does not exist. The plugin uses
   it in many different ways in many different places.
 *  Thread Starter [p15h](https://wordpress.org/support/users/prestonwordsworth/)
 * (@prestonwordsworth)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/http_host-in-local-environment-wp-cli/#post-16719462)
 * Got it! So in this case it seems best to just ignore the php warnings.
 *  Plugin Contributor [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/http_host-in-local-environment-wp-cli/#post-16719498)
 * Hi [@prestonwordsworth](https://wordpress.org/support/users/prestonwordsworth/),
   
   Yes just ignore the warnings…
 *  [thartl](https://wordpress.org/support/users/hartl/)
 * (@hartl)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/http_host-in-local-environment-wp-cli/#post-16956924)
 * Is there any better way to handle `$_SERVER['HTTP_HOST']` not beeing set, in `
   html_cache.class.php`?
   On servers running UNIX cron, a common crontab implementation
   is:`* * * * * cd /sites/example.com/files/; /usr/local/bin/wp cron event run --
   due-now >/dev/null 2>&1`So cron is fired via WP CLI. But the `$_SERVER` variable
   is not set up during WP CLI requests.Similarly, `$_SERVER['REQUEST_URI']` will
   not be defined, on the same line in `html_cache.class.php`.So logs for all our
   sites are filled with these warnings at all times.It’s not a functional problem,
   but makes our logs tough to navigate.This will be the case for those running 
   SpinupWP and other server panels.
 * Just a thought: you are already checking for WP_CLI in the `add_current_url_to_cache()`
   method. Moving the WP_CLI check above the `$current_url = "{$parts...` line fixes
   the problem. Would that work?
 * Thank you!
 *  Plugin Contributor [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/http_host-in-local-environment-wp-cli/#post-16959217)
 * Hi [@hartl](https://wordpress.org/support/users/hartl/),
   Can you please try out
   [this build of the plugin](https://verti-artifacts.s3.amazonaws.com/WP-Cloudflare-Super-Page-Cache-development-b9129a1b/wp-cloudflare-page-cache.zip)
   and let me know if this resolves your issue or not?
 *  [thartl](https://wordpress.org/support/users/hartl/)
 * (@hartl)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/http_host-in-local-environment-wp-cli/#post-17039636)
 * Hi [@isaumya](https://wordpress.org/support/users/isaumya/),
   Apologies about 
   the late reply. It looks like the link has expired.If you can update the link
   I will test it out.
 *  Plugin Contributor [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/http_host-in-local-environment-wp-cli/#post-17058452)
 * Hi [@hartl](https://wordpress.org/support/users/hartl/),
   Please [try this build](https://verti-artifacts.s3.amazonaws.com/WP-Cloudflare-Super-Page-Cache-development-b9129a1b/wp-cloudflare-page-cache.zip).
   Let me know if it works.
 *  [thartl](https://wordpress.org/support/users/hartl/)
 * (@hartl)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/http_host-in-local-environment-wp-cli/#post-17060176)
 * Hi [@isaumya](https://wordpress.org/support/users/isaumya/) ,
   thanks for the 
   updated link, however it gives me “access denied”. Can you have a look?
 *  Plugin Contributor [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/http_host-in-local-environment-wp-cli/#post-17060687)
 * Hi [@hartl](https://wordpress.org/support/users/hartl/),
   Sorry for that! [Try this link](https://verti-artifacts.s3.amazonaws.com/WP-Cloudflare-Super-Page-Cache-development-68d1609b/wp-cloudflare-page-cache.zip),
   I’ve checked it’s working.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘HTTP_HOST in local environment WP-CLI’ is closed to new replies.

 * ![](https://ps.w.org/wp-cloudflare-page-cache/assets/icon-256x256.gif?rev=3234997)
 * [Super Page Cache – Cloudflare Cache, Page Speed & Core Web Vitals](https://wordpress.org/plugins/wp-cloudflare-page-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-cloudflare-page-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-cloudflare-page-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-cloudflare-page-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-cloudflare-page-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-cloudflare-page-cache/reviews/)

## Tags

 * [cron](https://wordpress.org/support/topic-tag/cron/)
 * [wp-cli](https://wordpress.org/support/topic-tag/wp-cli/)

 * 9 replies
 * 3 participants
 * Last reply from: [iSaumya](https://wordpress.org/support/users/isaumya/)
 * Last activity: [2 years, 8 months ago](https://wordpress.org/support/topic/http_host-in-local-environment-wp-cli/#post-17060687)
 * Status: resolved