Title: HTTP_HOST warnings when using WP-CLI
Last modified: November 20, 2023

---

# HTTP_HOST warnings when using WP-CLI

 *  [efc](https://wordpress.org/support/users/eceleste/)
 * (@eceleste)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/http_host-warnings-when-using-wp-cli/)
 * This redirect plugin does not know how to “get out of the way” when commands 
   are being run from the WordPress CLI (wp-cli). For example, if this plugin is
   active and you execute `wp post list | count` from the command line, you will
   see this response before the actual count:
 *     ```wp-block-code
       PHP Warning:  Undefined array key "HTTP_HOST" in ./wp-content/plugins/quick-pagepost-redirect-plugin/page_post_redirect_plugin.php on line 2053
       Warning: Undefined array key "HTTP_HOST" in ./wp-content/plugins/quick-pagepost-redirect-plugin/page_post_redirect_plugin.php on line 2053
       PHP Warning:  Undefined array key "HTTP_HOST" in ./wp-content/plugins/quick-pagepost-redirect-plugin/page_post_redirect_plugin.php on line 2061
       Warning: Undefined array key "HTTP_HOST" in ./wp-content/plugins/quick-pagepost-redirect-plugin/page_post_redirect_plugin.php on line 2061
       ```
   
 * This is because the plugin assumes that `$_SERVER` includes an item with the 
   key `HTTP_HOST`, which is not true when WordPress is running from the command
   line (and also not true in a number of other cases).
 * At a minimum, this command should check with `array_key_exists()` before trying
   to use the `HTTP_HOST` key.
 * Better yet, the plugin should probably use the WordPress `get_site_url()` call
   to determine the host information instead of the `$_SERVER` information.
 * Best, the plugin should notice that it is being run from the CLI (check `if (
   defined( 'WP_CLI' ) && WP_CLI ) {...}`) before it takes certain actions that 
   just are not needed when running from the command line.

The topic ‘HTTP_HOST warnings when using WP-CLI’ is closed to new replies.

 * ![](https://ps.w.org/quick-pagepost-redirect-plugin/assets/icon.svg?rev=1156337)
 * [Quick Page/Post Redirect Plugin](https://wordpress.org/plugins/quick-pagepost-redirect-plugin/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/quick-pagepost-redirect-plugin/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/quick-pagepost-redirect-plugin/)
 * [Active Topics](https://wordpress.org/support/plugin/quick-pagepost-redirect-plugin/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/quick-pagepost-redirect-plugin/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/quick-pagepost-redirect-plugin/reviews/)

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [efc](https://wordpress.org/support/users/eceleste/)
 * Last activity: [2 years, 4 months ago](https://wordpress.org/support/topic/http_host-warnings-when-using-wp-cli/)
 * Status: not resolved