Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I serve Ionic app on a different port?

I'm trying to run the ionic project on browser but the default port 8000 is already in use.

I need to change the port

I'm using this command:

ionic run browser --port 8002 

but its not working.

The documentation says the port options are --port|-p

Thanks

like image 296
Alvaro Joao Avatar asked Sep 23 '16 13:09

Alvaro Joao


People also ask

How do you serve an ionic app?

By default, ionic serve boots up a development server on localhost . To serve to your LAN, specify the --external option, which will use all network interfaces and print the external address(es) on which your app is being served. Try the --lab option to see multiple platforms at once. ionic serve uses the Angular CLI.

How do I run my ionic app on real devices?

To run your app, all you have to do is enable USB debugging and Developer Mode on your Android device, then run ionic cordova run android --device from the command line. Enabling USB debugging and Developer Mode can vary between devices, but is easy to look up with a Google search.

Which of the below command is used to build an ionic app?

ionic build uses the Angular CLI. Use ng build --help to list all Angular CLI options for building your app.

What is ionic lab?

Ionic Labs allows you to preview your application working on the Android and iOS at the same time on the browser on the very same screen. This allows you to visualize changes on your app on all platforms at the same time so that you can quickly catch little quirks here and there.


2 Answers

Try ionic platform add browser before,

or

ionic serve -p 8002 --dev-logger-port 8103

instead...

like image 195
Juliano Petronetto Avatar answered Oct 18 '22 12:10

Juliano Petronetto


When running 2 ionic apps at the same time, it's not enough to specify a new port for the second app, you also need to specify a new port for live reload and dev logger or they will conflict with the first app:

ionic serve -p 8101 -r 8102 --dev-logger-port 8103 

Otherwise, you'll get connection error. Make sure firewall allows all those ports you use.

like image 22
Aditya Mittal Avatar answered Oct 18 '22 12:10

Aditya Mittal