How to Fix “PHP Notice: Undefined index: HTTP_HOST” with WP-CLI

22. February 2017 Note

Add code like following into wp-config.php or so.

if ( defined( 'WP_CLI' ) && WP_CLI && ! isset( $_SERVER['HTTP_HOST'] ) ) {
    $_SERVER['HTTP_HOST'] = 'example.com';
}


1 thought on “How to Fix “PHP Notice: Undefined index: HTTP_HOST” with WP-CLI”

  • 1
    Mike iLL on April 18, 2018 Reply

    Thanks for this, man. Very nice. It came up for me when I had wp-ytplayer-plus plugin enabled.

Leave a Reply

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