java.net.ConnectException:无法连接到 localhost/127.0.0.1(端口 9090):连接失败:ECONNREFUSED(连接被拒绝)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21626406/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 09:43:52  来源:igfitidea点击:

java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 9090): connect failed: ECONNREFUSED (Connection refused)

javaandroidodata4j

提问by user3060070

I am working with an App in Android. It uses a local host server in my PC to get some data. But I am getting warning in LotCat like this after running.

我正在使用 Android 中的应用程序。它使用我 PC 中的本地主机服务器来获取一些数据。但是我在运行后在 LotCat 中收到警告。

02-07 15:51:48.965: W/System.err(10339): com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 9090): connect failed: ECONNREFUSED (Connection refused)

02-07 15:51:48.965:W/System.err(10339):com.sun.jersey.api.client.ClientHandlerException:java.net.ConnectException:无法连接到 localhost/127.0.0.1(端口 9090):连接失败:ECONNREFUSED(连接被拒绝)

I am using a real device to connect to PC and run my App. android:permission:internethas been enabled in AndroidManifest.xml. The real device which I am using is hTC mobile with Androidv4.2.2. I am not using an asyncTask to call this webservice. Can anyone please help me....

我正在使用真实设备连接到 PC 并运行我的应用程序。android:permission:internet已在 AndroidManifest.xml 中启用。我使用的真实设备是带有 Androidv4.2.2 的 hTC mobile。我没有使用 asyncTask 来调用这个网络服务。谁能帮帮我吗....

回答by JH95

The URL should be 127.0.0.1:9090/URI.

URL 应为 127.0.0.1:9090/URI。

Furthermore ensure that you are on the same network as your server i.e make sure you are on the same wifi connection on the device as the server is on.

此外,请确保您与服务器在同一网络上,即确保您在设备上与服务器使用相同的 wifi 连接。

If this does not work the port may already be in use and you should try another port such as 4444.

如果这不起作用,则该端口可能已在使用中,您应该尝试另一个端口,例如 4444。