Localhost refused to connect <ionic>

I’ve ran the following commands:
“npm install -g cordova ionic”
“ionic start myApp”
“cd myApp”
“ionic serve”

Ionic Version: 3.5.0

I’m getting connection refused on localhost.

“ionic serve --verbose” gives me the following:

[DEBUG] Loading global plugin
[DEBUG] Loading local plugin
[DEBUG] Loading local plugin
[INFO] Starting app-scripts server: --log-level debug --port 8100 --p 8100 --livereload-port 35729 --r 35729 --address
0.0.0.0 - Ctrl+C to cancel
[15:54:10] watch started …
[15:54:10] build dev started …
[15:54:10] clean started …
[15:54:10] clean finished in 2 ms
[15:54:10] copy started …
[15:54:10] transpile started …
[15:54:13] transpile finished in 2.54 s
[15:54:13] preprocess started …
[15:54:13] deeplinks started …
[15:54:13] deeplinks finished in 14 ms
[15:54:13] preprocess finished in 14 ms
[15:54:13] webpack started …
[15:54:13] copy finished in 2.73 s
[15:54:22] webpack finished in 8.81 s
[15:54:22] sass started …
[15:54:23] sass finished in 1.16 s
[15:54:23] postprocess started …
[15:54:23] postprocess finished in 5 ms
[15:54:23] lint started …
[15:54:23] build dev finished in 12.56 s
[15:54:23] watch ready in 12.62 s
[15:54:23] dev server running: http://localhost:8100/

[INFO] Development server running
Local: http://localhost:8100

[15:54:26] lint finished in 2.65 s

It opens up the browser. But shows ERR_CONNECTION_REFUSED.

Does it connect in another browser?
Anything special about your network and internet connection? (Proxy, VPN)
Also post your ionic info output please.

Hi @Sujan12, thanks for the reply. The internet doesn’t have any proxy or connection issues. I’ve been running my ionic1 application smoothly.

Also, it is not able to connect to safari or firefox. I’ve tried them with ionic --browser “safar” or “firefox”

Here is my ionic info output :slight_smile:

global packages:

@ionic/cli-plugin-proxy : 1.3.2    
@ionic/cli-utils        : 1.5.0    
Cordova CLI             : 7.0.1
Ionic CLI               : 3.5.0

local packages:

@ionic/app-scripts              : 2.0.2    
@ionic/cli-plugin-cordova       : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms               : ios 4.1.1
Ionic Framework                 : ionic-angular 3.5.3

System:

Node       : v8.2.1
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.1
ios-sim    : 5.0.13
npm        : 5.3.0

ionic serve works for your Ionic v1 project?

My bad, it was. Actually, I’ve updated ionic to the latest version and it is again giving me the same error. Localhost refused to connect. I’ve developed an enterprise app with ionic1. It works amazing. Not sure what’s wrong with the ionic2. :slight_smile:

Have you tried serving the app on another port with ionic serve -p <port> ?

@domemue, yes I have. Same issue.

Can you run ionic server --verbose, then change a file so it rebuilds and post the whole output please.

@Sujan12, here’s the output:

[DEBUG] Loading global plugin @ionic/cli-plugin-proxy
[DEBUG] Loading local plugin @ionic/cli-plugin-cordova
[DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular
[INFO] Starting app-scripts server: --log-level debug --port 8100 --p 8100 --livereload-port 35729 --r 35729 --address
0.0.0.0 - Ctrl+C to cancel
[14:32:59] watch started …
[14:32:59] build dev started …
[14:32:59] clean started …
[14:32:59] clean finished in 2 ms
[14:32:59] copy started …
[14:32:59] transpile started …
[14:33:01] transpile finished in 2.76 s
[14:33:01] preprocess started …
[14:33:01] deeplinks started …
[14:33:01] deeplinks finished in 13 ms
[14:33:01] preprocess finished in 13 ms
[14:33:01] webpack started …
[14:33:01] copy finished in 2.90 s
[14:33:10] webpack finished in 8.40 s
[14:33:10] sass started …
[14:33:11] sass finished in 1.23 s
[14:33:11] postprocess started …
[14:33:11] postprocess finished in 5 ms
[14:33:11] lint started …
[14:33:11] build dev finished in 12.46 s
[14:33:11] watch ready in 12.52 s
[14:33:11] dev server running: http://localhost:8100/

[INFO] Development server running
Local: http://localhost:8100

[14:33:13] lint finished in 2.45 s
[14:33:20] build started …
[14:33:20] template update started …
[14:33:20] template update finished in 4 ms
[14:33:20] deeplinks update started …
[14:33:20] deeplinks update finished in 8 ms
[14:33:20] build finished in 15 ms

[14:33:20] build started …
[14:33:20] transpile started …
[14:33:22] transpile finished in 2.00 s
[14:33:22] deeplinks update started …
[14:33:22] deeplinks update finished in 3 ms
[14:33:22] webpack update started …
[14:33:23] webpack update finished in 278 ms
[14:33:23] build finished in 2.29 s

All locking fine - no indication what could be going wrong here :confused:

Not sure what the problem is but I am able to run by using --address.

ionic serve --lab --address localhost works but doesn’t live reload though. I’ve tried --livereload-port xyxy but doesn’t work. At least, I am somewhat unblocked for now.

Have a look around here and create an issue if you can’t find anything:
https://github.com/ionic-team/ionic-cli/issues
https://github.com/ionic-team/ionic-app-scripts/issues

enable CORS at your backend.