Title: Undefined array key &#8220;HTTP_HOST&#8221; PHP error
Last modified: June 6, 2023

---

# Undefined array key “HTTP_HOST” PHP error

 *  Resolved [nestormarius](https://wordpress.org/support/users/nestormarius/)
 * (@nestormarius)
 * [3 years ago](https://wordpress.org/support/topic/undefined-array-key-http_host-php-error/)
 * Hello,
 * My error_log file is full of this warning, which appears very random.
 * `PHP Warning: Undefined array key "HTTP_HOST" in /home/xxx/public_html/wp-content/
   plugins/ad-inserter/ad-inserter.php on line 11748`
 * Please investigate. Thank you!

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

 *  Thread Starter [nestormarius](https://wordpress.org/support/users/nestormarius/)
 * (@nestormarius)
 * [3 years ago](https://wordpress.org/support/topic/undefined-array-key-http_host-php-error/#post-16799175)
 * I believe it can be fixed by adding `$array['HTTP_HOST'] = [];`
 *  Plugin Author [Spacetime](https://wordpress.org/support/users/spacetime/)
 * (@spacetime)
 * [3 years ago](https://wordpress.org/support/topic/undefined-array-key-http_host-php-error/#post-16799789)
 * Hello,
 * please check this version:
   [https://downloads.wordpress.org/plugin/ad-inserter.zip](https://downloads.wordpress.org/plugin/ad-inserter.zip)
 *  Thread Starter [nestormarius](https://wordpress.org/support/users/nestormarius/)
 * (@nestormarius)
 * [3 years ago](https://wordpress.org/support/topic/undefined-array-key-http_host-php-error/#post-16803807)
 * [@spacetime](https://wordpress.org/support/users/spacetime/) thank you. I’ve 
   only pasted the new lines you’ve added in the ad-inserter.php file, which apparently
   define the HTTP_HOST array key.
 *     ```wp-block-code
           $host = isset ($_SERVER ['HTTP_HOST']) ? $_SERVER ['HTTP_HOST'] : '';
           if ($host == '' && isset ($_SERVER ['SERVER_NAME'])) {
             $host = $_SERVER ['SERVER_NAME'];
           }
       ```
   
 * and changed the modified line
 *     ```wp-block-code
           $url = remove_debug_parameters_from_url ((isset ($_SERVER ['HTTPS']) && $_SERVER ['HTTPS'] === 'on' ? "https" : "http") . '://'. $host . $_SERVER ['REQUEST_URI']);
       ```
   
 * So far no more errors. Thank you!

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

The topic ‘Undefined array key “HTTP_HOST” PHP error’ is closed to new replies.

 * ![](https://ps.w.org/ad-inserter/assets/icon-256x256.jpg?rev=1502039)
 * [Ad Inserter - Ad Manager & AdSense Ads](https://wordpress.org/plugins/ad-inserter/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ad-inserter/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ad-inserter/)
 * [Active Topics](https://wordpress.org/support/plugin/ad-inserter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ad-inserter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ad-inserter/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [nestormarius](https://wordpress.org/support/users/nestormarius/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/undefined-array-key-http_host-php-error/#post-16803807)
 * Status: resolved