How can I serve Ionic app on a different port? - browser

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

Try ionic platform add browser before,
or
ionic serve -p 8002 --dev-logger-port 8103
instead...

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.

ionic serve -p 9000
or
ionic serve --port 9000
simple

ionic serve --external --host="0.0.0.0" --port="8132"
that works for me (im running ionic on docker)
ionic version : 4.7.1
ionic cli version : 5.4.16

according to the issue tracker from the ionic team.. running commands like
ionic cordova run browser --port 8080
currently dont work, it seems to be a known issue and needs to be fixed within some cli version, not sure when this will be
https://github.com/ionic-team/ionic-cli/issues/2307
https://github.com/ionic-team/ionic-cli/issues/2312

you can also specify port and run in lab version using this command:
ionic serve -l --port 2020

This worked for me:
ionic serve -p 8200 -i 35730

Related

Ember Server: "Port 4200 is already in use", when no process runs on 4200

When running my ember application with ember serve -e local I get:
Port 4200 is already in use.
Which is weird because no application is running on 4200. I tried to open a dummy HTTP server on 4200 with http-server and it works just fine. It also works when I specify the port via a command line flag ember serve --port 4200.
Some things I've tried:
Restarted my computer.
Removed the node_modules.
Remove the ember tmp directory.
Disabled my firewall.
Tried with disabled wi-fi.
Any thoughts?
I'm running on masOS High Sierra 10.13.6 with the following versions:
node: 8.11.3
ember-cli: 2.18.2
npm: 5.6.0 (also tried with 6.3.0)
Also useful to know:
I have other ember applications running on my computer just fine.
I started to have this problem only recently.
In the past, macOS would keep asking me about authorizing incoming traffic whenever an app was opened, but now it stopped asking me.
I had this issue and tracked it down to using a string vs. integer for port in .ember-cli.
// .ember-cli
{
"port": 8080, // works
"port": "8080", // throws the error mentioned above
}
Not sure if this is the cause for others with this error. As mentioned, first thing is to make sure nothing else is actually running on that port. But OP had already checked that, and so had I.
After further investigation, it seems that the problem is not coming from macOS, but from something messed up in the dependencies causing ember-cli to fail...
It's not quite clear what is causing this, and I will try to post any additional information here, but for now if you happen to encounter this problem, just pass the port value directly to ember-cli like so:
ember serve --port 4200

Node web server not visible externally, but Python is (MacOS)

I'm just starting to build an Ionic 2 app, but I can't get it working on my mobile device.
Python (works)
To demonstrate that the phone can see the host, I tried a Python server:
$ python -m SimpleHTTPServer 8000
Serving HTTP on 0.0.0.0 port 8000 ...
If I go to http://192.168.8.101:8000 on my phone, it connects fine and displays the directory listing.
Node (fails)
However, when I start Ionic:
$ ionic serve -p 8000
[...]
[INFO] Development server running
Local: http://localhost:8000
External: http://192.168.8.101:8000
I can load it in my host's web browser, but I can't see it from my phone nor another computer (it times out). I also tried a basic node server:
$ npm install http-server -g
$ http-server -p 8000
Starting up http-server, serving ./
Available on:
http://127.0.0.1:8000
http://192.168.8.101:8000
With the same result as Ionic: accessible from the host, but not from the phone.
Is there something blocking the request? Or is there some Node configuration I'm missing? I'm new to both Mac OS and Node, so I don't know where to look.
Embarrasingly, this turned out to be a firewall issue. In System Preferences > Security & Privacy > Firewall > Firewall Options, Node was explicitly set to deny incoming connections:
Changing it to Allow has fixed it. Phew!
Just execute ionic address and you'll get an IP address in your command line. Try with that ipaddress:port number from your mobile which will enable you to access your site from your phone.
Just incase if the ionic address command doesn't return anything, you need to execute the below command to point it to your ip,
ionic serve --address YOUR_IP_ADDRESS
Hope this helps!

Application generated with JHipster 4 returning blank page on 8080, but not on 9000

I've create an application with JHipster v4. When I make a request on port 8080 it is returning a blank page. If I use yarn start, and I make a request to 9000 port, it is answering correctly.
Any idea?
I had the same issue with JHipster application bringing up the blank page on port 8080 when ran with ./mvnw in dev mode. I was able to resolve this by running:
yarn install && yarn webpack:build
After it finishes, the application shows normally in dev mode on port 8080.
I had the same issue where on port 8080, it was returning nothing and on 9000 it gave correct page , after
yarn install && yarn webpack:build
I get correct page on both, I noticed that if I only run .mvnw, the application runs fine and I do not need to run "yarn start"
By default, yarn listens on port 9000 (webpack + browser sync) to hot reload frontend code and contents, maven or gradle listens on port 8080 to hot reload server code. You must run both in dev.
If you start making changes to the client side code without having yarn start running, nothing will be reflected as the changes are not compiled so you need to either run yarn webpack:build manually after changes or have yarn start running.
It's written in the README.md of the project you generated and is documented on JHipster web site.
You should run npm install then mvnw, and it will run good.
For me (using npm for the front-end), just running npm start before mvnw makes the front-end available on 8080.
On the other hand, running npm start after mvnw will bring a blank page on 8080.

Can't see my server on an azure vm

I have an Azure vm with Ubuntu 12 and I want to make an Angular2 server with angular-cli. When I run ng serve --port 80 I just can't see the page with a browser. When I check with CURL from the vm I can see the HTML properly but I get an error when I try to see it from the internet.
The strangest thing is that anything else I try works perfectly, I also have an old node server on the vm and when I run that I can see it normally from CURL and from the internet.
Okay so apparently I needed to specify host : sudo ng serve --host 0.0.0.0 --port 80.
github.com/angular/angular-cli/issues/2375
Thanks to evilSnobu.

phonegap changing from port 3000

On the c9 IDE(c9.io) i installed node and phonegap globally, and started to build an app.
I can run the app on port 3000 by usign the command: phonegap serve
but i would like to run in a diferent port, using:
.listen(process.env.PORT, process.env.IP);
that is the way to run node app on c9.io:
https://docs.c9.io/docs/writing-a-nodejs-app
I am having trouble to find the file to edit and change the port.
Thanks
phonegap serve -b $IP -p $PORT
thant is the command to run on c9

Resources