Ask coding questions

← Back to all posts
How to open the localhost in riplit
JuanCarrion2 (0)

I'm running an Angular/Ionic 5 Web App in Riplit.

When running the app, it complies and tells me that the ANgular Live Server is running on Localhost: 4200.

===================
Date: 2021-05-03T20:59:45.892Z - Hash: 6d16985704fcaf4e31bf - Time: 50685ms
Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/

ℹ 「wdm」: Compiled successfully.

When I click on the link, it tries to open localhost:4200 in the local machine, but nothing loads.

I'm thinking it's because it's actually running on the VM.

How do I access the localhost in the VM?

Thanks in advance. Cheers!

Comments
hotnewtop
BD103 (139)

Angular is probably trying to run on 127.0.0.5, which is a local IP that cannot be accessed outside of the machine/WiFi. See if you can configure it to run on 0.0.0.0, which allows access from the outside world.

Try ng serve --host 0.0.0.0. I just got this from the Angular docs, so that may not work. Tell me if it doesn't, so we can fix it!

BD103 (139)

Also, this is a Replit specific answer. If you are trying this on your computer / own server then it would be a bad practice.

JuanCarrion2 (0)

@BD103 Thanks for the answer. So if I understood correctly, set the ng serve --host 0.0.0.0

However, after it finishes compiling, do I just need to open a webrowser and navigate to 'localhost' or do I need to put the IP of the machine. Thanks in advance!

BD103 (139)

If you are on Repl.it, then a box with the website should pop up. (The format is <replname>.<user>.repl.co.) If you are running this through your machine, then try executing ng serve --host 127.0.0.5 --port 8000. Then you can open up your browser (Chrome, Safari, etc.) and go to https://127.0.0.5:8000.

Opening to 0.0.0.0 on your computer can be dangerous, as it allows people from outside your network to access your device. Replit relies on this, but you shouldn't.
@JuanCarrion2