HTTP_HOST not found #228

juanjolainez opened this Issue Jun 5, 2014 · 7 comments


None yet

3 participants


Hello, after a composer update, I am getting this error:

{"error":{"type":"ErrorException","message":"Undefined index: HTTP_HOST","file":"/home/clipster/development/vendor/hybridauth/hybridauth/hybridauth/Hybrid/Auth.php","line":388}}

Do you know what is for?

Thank you! :D

@StorytellerCZ StorytellerCZ added this to the 2.2.x milestone Jun 6, 2014
@StorytellerCZ StorytellerCZ added the 2.2.x label Jun 6, 2014
@StorytellerCZ StorytellerCZ removed this from the 2.2.x milestone Jul 11, 2014

I think it references this:
$url = $protocol . $_SERVER['HTTP_HOST'];
But why that would create an error I don't know.

@StorytellerCZ StorytellerCZ added 2.3.x and removed 2.2.x 2.3.x labels Jul 16, 2014

@juanjolainez can you check with a print_r($_SERVER) of the HTTP_* variables are set on your configuration?


Nope, HTTP_HOST is not set when I make a print_r($SERVER)....


@juanjolainez on what kind of environment are you running? i.e. PHP version, Windows / Linux, used browser to test etc


It only fails when I do composer update.

I've test it in both Linux and MAC with PHP 5.5.3. No browser. If I comment from that line to the end of the function it works just fine, but it's pretty annoying to do so every time.

It works when I use it by doing API calls or browser calls


It happens when I do some job in a queue (actually I am syncing friends using social networks) and I am getting the very same error.

Do you have any thoughts about this?

Thank you


Actually I figured out the issue.

The point is as I am doing a cli call instead of a browser call, some variables are not set (it's the very same case as when you do it with PHPUnit).

I commented this lines in the file Auth.php (line 388):

$url = $protocol . $_SERVER['HTTP_HOST'];

    // use port if non default
    if( isset( $_SERVER['SERVER_PORT'] ) && strpos( $url, ':'.$_SERVER['SERVER_PORT'] ) === FALSE ) {
        $url .= ($protocol === 'http://' && $_SERVER['SERVER_PORT'] != 80 && !isset( $_SERVER['HTTP_X_FORWARDED_PROTO']))
            || ($protocol === 'https://' && $_SERVER['SERVER_PORT'] != 443 && !isset( $_SERVER['HTTP_X_FORWARDED_PROTO']))
            ? ':' . $_SERVER['SERVER_PORT'] 
            : '';

    if( $request_uri ){
        $url .= $_SERVER['REQUEST_URI'];
        $url .= $_SERVER['PHP_SELF'];

and everything seems to work fine.

A fix would be adding an isset httphost just like this:

if (array_key_exists('HTTP_HOST', $_SERVER) {


if (php_sapi_name() == cli) {

What do you think? Thank you!

@borNfreee borNfreee added a commit to borNfreee/hybridauth that referenced this issue Dec 24, 2014
@borNfreee borNfreee Fixes #228 - HTTP_HOST not found
Do not try to get `current url` when it's called from CLI. Fixes #228
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment