1

I am trying to access my angular application which is running on http://localhost:4200 . I have tried changing localhost to my actual IPV4 address 192.168.43.XXX but I m receiving the following message from the browser "This site can’t be reached".

Using http://127.0.0.1:4200 works just fine. I am running the application using ng serve.

I have tried turning off the firewall but nothing changes.

Is it necessary to run the application like this ng serve host 192.168.43.XXX ?

If so, why ?

If I remember correctly I have managed to connect from my phone using only ng serge a year ago.

Cristian Flaviu
  • 275
  • 2
  • 7
  • 18
  • I don't want my application to be usable outside my Lan for now, later I will deploy it on a website. I was trying to connect to http://192.168.43.XXX:4200, so the port was specified. – Cristian Flaviu Apr 19 '21 at 19:07
  • this may help you: https://stackoverflow.com/questions/37762125/set-default-host-and-port-for-ng-serve-in-config-file – David B. Apr 20 '21 at 13:11

1 Answers1

1

To access your Angular Web app across computers in the same LAN, you'll need to serve and host your angular App in the CLI as so:

ng serve --host 192.172.0.402 --port 4500

Where 192.172.0.402 is your PC's IP address, while 4500 is your custom service port. Your PC will be the server within the LAN.

  • Be sure to add your PC IP address to allowed CORS in your setting.py esp. when you're dealing with django auths for example.