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

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';
}

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';
}
Thanks for this, man. Very nice. It came up for me when I had wp-ytplayer-plus plugin enabled.