It is invalid to use ng server to start other people's access in the local area network in the angular4 project.

after using ng server in angular4 project, you can open it locally with localhost:4200. In the local area network, others can"t access my project with my local area network address.

Feb.28,2021

run ng serve-host xxx.xxx.x.xxx (your own ip address), and then you can access it through your ip address.
seems to be configurable in the project. If configured, you can run ng serve directly. I forgot how to do it.


localhost is actually a domain name, similar to baidu.com . The corresponding IP address is usually 127.0.0.1, which can only be accessed by local applications on your own computer, even in the same local area network. He typed localhost into his browser to access applications on his computer. So you can follow the practice upstairs, set up your application from the server's ip is the IP address of your computer, so that other people on the same local area network can access it.

Menu