java.net.ConnectException: fail to connect to localhost/127.0.0.1(port 8080): connect failed:ECONNREFUSED….(Codename One App)

前端 未结 3 1121
深忆病人
深忆病人 2020-12-14 12:24

After build android application , I scanned the generated QRcode and install the application on galaxy s4 successfully. But when I try to do some search using the app I got

相关标签:
3条回答
  • 2020-12-14 12:41

    I have launched local API server, so i have problems with connecting through IP address.

    I found one solution, which helped me - you run your API server, start your emulator, and then you go to android ADB in CMD (path should be something like ....\AppData\Local\Android\Sdk\platform-tools). Then you go to that directory, just type in command: adb reverse tcp:8080 tcp:8080, and you should be able to reach it. Run your android app, problem should be solved.

    More about reverse proxy.

    0 讨论(0)
  • 2020-12-14 12:43

    From the emulator, 127.0.0.1 refers to the emulator itself - not your local machine. You need to use ip 10.0.2.2, which is bridged to your local machine.

    HTH!

    0 讨论(0)
  • 2020-12-14 12:53

    It looks like you're trying to connect to localhost in your URL.

    This probably works fine using the simulator, but you'll need to use an IP address or better yet a resolvable host name in your URL when you run the app in production.

    Try changing your URL in this way. You can test for connectivity by using your phone's web browser, for example enter a URL (not using localhost!) of your web service in the browser and see what happens.

    0 讨论(0)
提交回复
热议问题