Can't access localhost. Ionic Serve, Run and Build commands are broken


#1

Wherever I try to perform any of these commands, I get error messages:

  • ionic serve >>> Browser (Firefox or Chrome) do not connect do localhost. It only works if a set another IP using “ionic address” -> choose IP diferent from localhost -> “ionic serve”.

  • ionic run android >>> “Error executing “adb devices”: error: could not install smartsocket listener: cannot bind to 127.0.0.1:5037” and other things (see below)

  • ionic build android >>> “java.io.IOException: Unable to establish loopback connection” and other things (see below)

-----IMPORTANT-----

  1. I have been using Ionic for 15 days, running those commands succesfully several times.
  2. These errors started to occurr after I manully close the command prompt and the Android Emulator windows in the middle of an “ionic emulate” operation (such a small thing could cause these problems?).

—System Status----
Ionic 1.7.13
Node 5.5.0
Cordova 6.0.0
NPM 3.3.12
Java JDK 1.7.0_45 and 1.8.0_71
Android SDK - Almost all packages (see: http://tinypic.com/r/2irr80l/9)
Windows 8.1

—Firewalls—
Antivirus: Kaspersky -> disabled
Windows firewall -> disabled

----System variables----
JAVA_HOME C:\Program Files\Java\jdk1.8.0_71
ANDROID_HOME C:\Users\EscolhaFacil\AppData\Local\Android\android-sdk
PATH C:\Users\EscolhaFacil\AppData\Local\Android\android-sdk\platform-tools;C:\Users\EscolhaFacil\AppData\Local\Android\android-sdk\tools;C:\Users\EscolhaFacil\AppData\Roaming\npm and dozens of other things

—Solutions that I tried, but didn’t solved the problem----

  1. adb kill-server then adb start-server
  2. adb -P 5038 start-server (start ADB server on onther port, default is :5037)
  3. adb -H 192.168.1.56 start-server (start ADB server on the same IP that I get “ionic serve” to work)
  4. manually kill “adb.exe” on task manager

-----Complete ERROR LOGs---------
See: http://pastebin.com/ukbRhN1w

-----Complete nestat report---------
After 'adb start-server’
After ‘ionic serve’ for localhost (that didn’t opened on the browser)

See: http://pastebin.com/YAEW3LrR
*PID 4552 - adb.exe
*PID 5340 - node.js


#2

In a command prompt try to ping localhost. If that fails it could be your hosts file or DNS is clobbered. Ipconfig /flushdns. Try to ping localhost again. If still bad check your windows/system32/drivers/etc/hosts file.


#3

@A_Burgess

  1. ping 127.0.0.1 -> OK, TTL 128
  2. Ipconfig/flushdns - OK
  3. Hosts file - I believe that localhost access is handle by DNS, but anyway I add the line “127.0.0.1 localhost” to sytem32/hosts

The problem is still there.

I also tried: http://stackoverflow.com/questions/813347/http-localhost-not-working-on-windows-7-whats-the-problem

------Something weird----------

  1. Task Manager -> Kill “adb.exe”
  2. Command prompt -> ionic run android
  3. Task manager shows that two new “adb.exe” are created: http://tinypic.com/r/fk07qg/9
  4. Ionic trows error “could not install smartsocket listener”

Considering that is only possible to have one proccess running (listening) in port 127.0.0.1:5037, why the “ionic run” command tries to initiate two instances of adb.exe?


#4

The best thread I could find about this is at https://code.google.com/p/android/issues/detail?id=184713 but you seem to be having a very slightly different issue. Ptrobably still worth going through that thread and checking it out.

I use kaspersky as you do but even with it enabled I have no issues.


#5

I am having the same issue, everything was working until I updated my project to Cordova 6.3.1 and Ionic 2.0.0.

Using Genymotion as a Virtual Device (both run and emulate fail)

Update: Works if I run it on a physical Android Device.

Update 2: It was an Issue with Genimotion, please see this link for solution: https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=182346


#6

Hi did you find a solution? What was it?