DEV Community

loading...

How to access localhost from other devices within the same network?

Farith Adnan
Aspiring young developer who love to learn and exploring new things in the tech world.
・1 min read

wtf!

Introduction

  • Usually, during the web-development using Angular it's require for the project to be run locally but what if we want to access our project from other devices, can we do that with Angular?

  • The answer is of course we can! with Angular we can also grant access to other devices BUT you need to make sure that the external devices is within the same network as your project host (localhost).

Enough with the introduction, let's jump into it!

Access Local Project From Other Devices

  • As we all know, when we want to run our project in Angular we just need to open the terminal in our code editor or whatever terminal your usually use and run the command below right?

    ng-serve


  • But if you want to access the project from other devices within the same network you only need to run:

ng-serve --host 0.0.0.0


  • and done! you now only need to enter the URL below from other devices within your network to access to your localhost by specify your Ip Address and the Angular project port.

http://192.xxx.x.x:4200

Thanks for reading! for any question or enquires please send me a message or comment down below

Discussion (1)

Collapse
yoursunny profile image
Junxiao Shi

There could be behavioral difference between localhost and HTTP access on an IP address, if you use advanced features such as WebCrypto. Those features are only available when the webpage is loaded from a *secure origin *. localhost is considered secure even if it's unencrypted HTTP, while HTTP access to an IP address is not a secure origin.