question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ionic serve launches browser to "Invalid Host header" only

See original GitHub issue

Bug Report

Ionic Info

Ionic:

   ionic (Ionic CLI)          : 4.0.1 (/home/david/.nvm/versions/node/v9.11.2/lib/node_modules/ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.0
   @angular-devkit/core       : 0.7.0-rc.3
   @angular-devkit/schematics : 0.7.0-rc.3
   @angular/cli               : 6.0.8
   @ionic/ng-toolkit          : 1.0.0
   @ionic/schematics-angular  : 1.0.1

System:

   NodeJS : v9.11.2 (/home/david/.nvm/versions/node/v9.11.2/bin/node)
   npm    : 5.6.0
   OS     : Linux 4.14

Describe the Bug

In a new Ionic v4 beta project when I simply run ionic serve it launches a browser but only displays the message “Invalid Host header” as the only page content.

Steps to Reproduce Steps to reproduce the behavior:

(Follow exact steps in docs for a new v4 beta project.)

  1. npm install -g ionic
  2. ionic start myApp tabs --type=angular
  3. ionic serve
  4. See error in browser

Related Code

N/A

Expected Behavior

That it launches the app content in the browser.

Additional Context

I’m on a Pixelbook so running inside a LXC container so this issue might be limited to containers.

Maybe a workaround would be to configure webpack to work with the Chrome OS Linux LXC container (aka Crostini) default hostname of penguin.linux.test?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:29 (12 by maintainers)

github_iconTop GitHub Comments

6reactions
imhoffdcommented, Feb 22, 2020

Hello all (especially @DavidFrahm @eslindsey @philips @kevin-brotcke) 👋

I have implemented the --public-host option for the Ionic CLI which should resolve all issues here. This option provides a way for devs to specify which host the browser should use, regardless of which host the dev server is bound to.

Please help me test this PR by installing a test version of the Ionic CLI:

npm i -g @ionic/cli@6.2.0-testing.5

Couple things to note:

  • --address is now named --host
  • the default host is localhost, not 0.0.0.0
  • use ionic serve --host=0.0.0.0 --public-host=<hostname> to test

Let me know what you think! 💙

4reactions
thielpetercommented, Feb 19, 2020

I used:

ionic serve --port 8080 --address 0.0.0.0 -- --disableHostCheck true

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix "invalid host header" in Angular - Stack Overflow
In most cases, the fix is to tell the server to restart and allow connections from outside localhost. ng (Angular) => Kill the...
Read more >
Ionic serve launches browser to "Invalid Host header" only
Ionic serve launches browser to "Invalid Host header " only.
Read more >
What is this “Invalid Host Header” error? | by Avinash Thakur
This error is most commonly caused by a misconfiguration of the application server that causes it to reject non-local connections.
Read more >
Origin is always present on proxy for ionic serve
The Service Proxy of Ionic CLI enables you to request URIs that are not on localhost (from where ionic serve … serves) which...
Read more >
X-Frame-Options - HTTP - MDN Web Docs
The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found