An error occurred while reading the file from Tomcat by Android: connect failed: econnrefused

Source: Internet
Author: User
When Android reads a file from tomcat, the following exception occurs:

08-10 14:53:09. 118: W/system. Err (12527 ):
Java.net. connectexception: failed to connect to localhost/127.0.0.1 (port 8080 ):
Connect
Failed: econnrefused (connection refused)
08-10 14:53:09. 118: W/system. Err (12527): At libcore. Io. iobridge. Connect (iobridge. Java: 114)
08-10 14:53:09. 128: W/system. Err (12527): At java.net. plainsocketimpl. Connect (plainsocketimpl. Java: 192)
08-10 14:53:09. 128: W/system. Err (12527): At java.net. plainsocketimpl. Connect (plainsocketimpl. Java: 459)
08-10 14:53:09. 128: W/system. Err (12527): At java.net. Socket. Connect (socket. Java: 842)
08-10 14:53:09. 158: W/system. Err (12527): At libcore.net. http. httpconnection. <init> (httpconnection. Java: 76)
08-10 14:53:09. 158: W/system. Err (12527): At libcore.net. http. httpconnection. <init> (httpconnection. Java: 50)
08-10 14:53:09. 158: W/system. Err (12527): At libcore.net. http. httpconnection $ address. Connect (httpconnection. Java: 340)
08-10 14:53:09. 168: W/system. Err (12527): At libcore.net. http. httpconnectionpool. Get (httpconnectionpool. Java: 87)
08-10 14:53:09. 168: W/system. Err (12527): At libcore.net. http. httpconnection. Connect (httpconnection. Java: 128)
08-10 14:53:09. 178: W/system. Err (12527): At libcore.net. http. httpengine. opensocketconnection (httpengine. Java: 316)
08-10 14:53:09. 178: W/system. Err (12527): At libcore.net. http. httpengine. Connect (httpengine. Java: 311)
08-10 14:53:09. 178: W/system. Err (12527): At libcore.net. http. httpengine. sendsocketrequest (httpengine. Java: 290)
08-10 14:53:09. 178: W/system. Err (12527): At libcore.net. http. httpengine. sendrequest (httpengine. Java: 240)
08-10 14:53:09. 208: W/system. Err (12527): At libcore.net. http. httpurlconnectionimpl. getresponse (httpurlconnectionimpl. Java: 282)
08-10 14:53:09. 208: W/system. Err (12527): At libcore.net. http. httpurlconnectionimpl. getinputstream (httpurlconnectionimpl. Java: 177)
08-10 14:53:09. 208: W/system. Err (12527): At com. example. androidstudy. utils. httpfiledownloadutils. Download (httpfiledownloadutils. Java: 31)
08-10 14:53:09. 218: W/system. Err (12527): At com. example. androidstudy. filedownloadactivity $1 $1. handlemessage (filedownloadactivity. Java: 36)
08-10 14:53:09. 218: W/system. Err (12527): at Android. OS. handler. dispatchmessage (handler. Java: 95)
08-10 14:53:09. 232: W/system. Err (12527): at Android. OS. low.loop (low.java: 137)
08-10 14:53:09. 232: W/system. Err (12527): at Android. OS. handlerthread. Run (handlerthread. Java: 60)
08-10 14:53:09. 238: W/system. Err (12527): caused by: libcore. Io. errnoexception: connect failed: econnrefused (connection refused)
08-10 14:53:09. 251: W/system. Err (12527): At libcore. Io. POSIX. Connect (native method)
08-10 14:53:09. 251: W/system. Err (12527): At libcore. Io. blockguardos. Connect (blockguardos. Java: 85)
08-10 14:53:09. 251: W/system. Err (12527): At libcore. Io. iobridge. connecterrno (iobridge. Java: 127)
08-10 14:53:09. 258: W/system. Err (12527): At libcore. Io. iobridge. Connect (iobridge. Java: 112)
08-10 14:53:09. 258: W/system. Err (12527):... 19 more

Solution:

String url = "http: // localhost: 8080/notice/test.txt"; modify it to string url = "http: // 192.168.1.100: 8080/notice/test.txt ";

The Host IP address cannot use localhost or 127.0.0.1. Use the real IP address.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.