I have an app generated with Angular CLI from scratch. CLI version angular-cli: 1.0.0-beta.11-webpack.2
I am trying to test it from my smartphone but I get Connection refused.
So, I run ng serve
on my laptop and try to access the app:
localhost
: WorksThis used to work with the previous, SystemJS version of CLI. I checked that I don't have a firewall running.
How could I fix or debug this error?
I am using a Mac.
Angular is an excellent tool for building any kind of mobile app. Naturally, you can use this framework to build a web application that runs on any device. However, you can combine Angular with NativeScript, another open-source framework that allows building iOS and Android.
ng servelink. Builds and serves your application, rebuilding on file changes.
Adding the host-flag with value "0.0.0.0" should allow you to access the webserver from any device on your local network.
This should work: ng serve --host 0.0.0.0
For an explanation: https://github.com/angular/angular-cli/pull/1475#issuecomment-235986121
In package.json
"start": "ng serve --host 0.0.0.0 --port 4200 --disable-host-check ",
However --disable-host-check
would be a security risk and you will need "@angular/cli": "^1.1.0-rc.2"
as this flag appeared in 1.1 version
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With