When running ionic serve --all or ionic serve --address=0.0.0.0, it appears that the server bind command switches to localhost before passing it to express.listen(that happens here). I'm not 100% sure due to not being super well-versed in express, but I believe that's just binding to localhost which makes doing something like ionic serve from inside of a docker container not work appropriately.
This _does_ work in [email protected], however.
That binding to 0.0.0.0 would allow me to bind to every incoming address instead of just localhost.
Steps to reproduce:
ionic serve --address=0.0.0.0 in an ionic 1 projectPost the output of ionic info below please
global packages:
@ionic/cli-utils : 1.0.0
Cordova CLI : You have been opted out of telemetry. To change this, run: cordova telemetry on. 7.0.1
Ionic CLI : 3.0.0
local packages:
@ionic/cli-plugin-cordova : 1.0.0
@ionic/cli-plugin-ionic1 : 1.0.0
Ionic Framework : ionic1 1.3.2
System:
Node : v6.10.3
OS : Linux 4.9
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)
There was a very old issue https://github.com/driftyco/ionic-cli/issues/322 which addressed this problem a while back, as well as a slightly more recent issue making 0.0.0.0 the default - https://github.com/driftyco/ionic-cli/issues/675. I've tried to follow the trail up to v3 of the API but I've not found any breadcrumbs - though that could well be my googlefu failing me.
Mostly I'm curious if this was an intentional change in behavior (or if I'm missing something), since it's pretty clearly checking for the 0.0.0.0 in the linked code. I this _seemed_ like it was a regression given the 2 previous tickets - hence the ticket and I couldn't find the reasoning through searching.
If this is better as a forum post, I'd be happy to take it over there.
@cthos The line of code you linked doesn't make sense to me. 0.0.0.0 should be allowed. This may miss the window for the next release, but I'll investigate it soon.
@cthos Should be fixed for you in the next version when it's released. Thanks for the great bug report! 馃憤
Awesome! Thank you!
i'm same, this issue after ionic serve open http://0.0.0.0:8100 and show code eror "This site can鈥檛 be reached".
how to fix this issue?
thanks before.
+1
i resolved with ionic cordova serve --address=localhost --port=8100