Why "ionic serve" fails?


#1

Hi,

I’m trying to run “ionic serve” in order to run my app in the browser. But, unfortunately, I got this error:

$ ionic serve
Running serve task...
Running dev server at http://0.0.0.0:8100

... Uhoh. Got error listen EADDRINUSE ...
Error: listen EADDRINUSE
    at errnoException (net.js:904:11)
    at Server._listen2 (net.js:1042:14)
    at listen (net.js:1064:10)
    at Server.listen (net.js:1138:5)
    at Server.listen (/usr/local/lib/node_modules/ionic/node_modules/tiny-lr-fork/lib/server.js:138:15)
    at Object.IonicServeTask._start (/usr/local/lib/node_modules/ionic/lib/ionic/serve.js:70:12)
    at Object.IonicServeTask.run (/usr/local/lib/node_modules/ionic/lib/ionic/serve.js:35:8)
    at Object.Ionic.run (/usr/local/lib/node_modules/ionic/lib/ionic.js:192:13)
    at Object.<anonymous> (/usr/local/lib/node_modules/ionic/bin/ionic:10:7)
    at Module._compile (module.js:456:26)

What could be wrong?
I use Ionic 1.0.11.

Thanks!


#2

Normally this means that you have another process using that address, try check what you have open and closing any servers running locally.


#3

ps aux | grep node did not reveal anything. But, closing the terminal and opening it again solved the problem. Thanks!


#4

The error message is a bit misleading. It doesn’t have to do with the address but the port. Specifically it could be either the web server 8100 or livereload 35729. For me it was live reload. Just launch ionic serve with custom ports.

Command: ionic serve [http-port] [livereload-port] [options]

Example: ionic serve 8101 35739


#5

The error message is indeed misleading. In my case it was ember server using the same port for live reload.


#6

I think the port is not being set in my case:

ionic run android -l -p 9999 -r 9998 -c

> ionic-hello-world@ ionic:serve /home/pills/code/reusecentral-ionic
> ionic-app-scripts serve "--v2" "--runLivereload" "--isPlatformServe" "--port" "9999" "--livereload-port" "9998" "--consolelogs" "--livereload" "--address" "192.168.1.102" "--iscordovaserve" "--nobrowser"

[15:51:41]  ionic-app-scripts 0.0.45 
[15:51:41]  watch started ... 
[15:51:41]  build dev started ... 
[15:51:41]  clean started ... 
[15:51:41]  clean finished in 1 ms 
[15:51:41]  copy started ... 
[15:51:41]  transpile started ... 
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE 0.0.0.0:53703

Note I am not using 53703. Instead 9998 and 9999.