Ionic serve to start on specific IP

When running ionic serve on our production server I see this:

Gulp startup tasks: [ 'sass', 'watch' ] Running dev server: http://localhost:8100 Running live reload server: http://localhost:35729 Watching : [ 'www/**/*', '!www/lib/**/*' ] Ionic server commands, enter: restart or r to restart the client app from the root goto or g and a url to have the app navigate to the given url consolelogs or c to enable/disable console log output serverlogs or s to enable/disable server log output quit or q to shutdown the server and exit

Which means I cannot access the app from a browser as its only listening for localhost. How can I change localhost to the actual server IP?

Thanks

Please try this. @luaneswart
ionic serve --address YOUR_IP_ADDRESS

Please note that YOUR_IP_ADDRESS should be an available IP which is assigned to your actual device. For example if your (static or dynamic) IP address is 192.168.0.110, you cannot do “ionic serve” with 192.168.0.111 or 192.168.0.112 etc.

3 Likes

Hi, I got it to work by doing “ionic address” and then simply choosing the address I wanted :smile:

4 Likes

Awesome, I also learnt a thing or two. :ok_hand:

You can just type ionic help serve to see what options are available, or ionic help to see all the commands.

when I use command ‘ionic serve --address 192.168.0.2’, i got errors.
The address only could be changed by command ‘ionic address’, and then select a ip from the given list.
However, I can’t find the command option ‘ionic address’ in the help.
I think it’s a tiny bug. :mask:

That’s because your device is not assigned with such an IP of 192.168.0.2.

This one is how to chose some_ip/locahost once again. :wink:

Just update you CLI

dev server running: http://localhost:8100/

to make your ip adress to work in VPS

Follow this steps
Install the Ionic CLI

The easiest way to get the Ionic CLI is through npm.

$ npm install -g ionic

Note: For a global install of -g ionic, OSX/Linux users may need to prefix the command with sudo.
Update Ionic lib

Update Ionic library files, which are found in the www/lib/ionic directory. If bower is being used by the project, this command will automatically run bower update ionic, otherwise this command updates the local static files from Ionic’s CDN.

$ ionic lib update