Ionic Serve starts fine, but app won't load in browser

I installed the vagrant box with the installer. I am logged in to ssh. I had to do a few things to get everything working (for example, install gulp manually - I saw a gulp error when I ran ionic setup sass at the end of the command) but it all seems to be working now.

At the question prompt when I ran ionic serve I choose option 2, localhost. I see it start up with localhost:8100 for the dev server and :35729 for the live reload server. But when I try to access this from my browser on my Windows 8 box, the page cannot be loaded.

Is there something else I’m missing? Thanks

1 Like

when you try to go to localhost the browser will go main machine (windows pc) server not the vagrant box.
if you want to use the vagrant box as localhost u need to edit the windows hosts file or
enter the vagrant ip in the browser with the port number.

Thank you for the response.

I’m new to virtual machines, but because I ssh’d to 127.0.0.1, I figured that I could navigate to the site hosted on the vagrant box with ionic serve the same way. I also just did ifconfig and found the inet address of 10.0.2.15 which was the first option when I first ran ionic serve. I tried visiting 10.0.2.15:8100 from my local machine (not the vagrant box) but to no avail.

I really am not concerned with which hostname/ip I use to navigate to the site; I’m just trying to actually navigate to it from my local machine. Do you have any ideas?

Thank you for the help! I figured out the solution, thanks to this website post.

I needed to add the following two lines to my Vagrantfile to forward the ports properly:

config.vm.network :forwarded_port, host: 8100, guest: 8100
config.vm.network :forwarded_port, host: 35729, guest: 35729

It would be nice to see this added to either the Getting Started page or the Ionic Box page, as a notice for local development with Vagrant. Thanks again!

1 Like

you have 2 options;

  1. learn vagrant port forwards in vagrant site:
    https://docs.vagrantup.com/v2/networking/forwarded_ports.html

  2. just run the project on your local machine,
    node server or xampp or what you want.