• URLConnection程序报java.net.ConnectException: Connection refused: connect


    java.net.ConnectException: Connection refused: connect
        at java.net.DualStackPlainSocketImpl.connect0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:606)
        at java.net.Socket.connect(Socket.java:555)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
        at sun.net.www.http.HttpClient.(HttpClient.java:242)
        at sun.net.www.http.HttpClient.New(HttpClient.java:339)
        at sun.net.www.http.HttpClient.New(HttpClient.java:357)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1226)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:990)
        at com.kangning.web.test.protocol.URLTest.testOpenConnection(URLTest.java:60)
        at com.kangning.web.test.protocol.URLTest.main(URLTest.java:92)

    解决办法:

    java.nect.ConnectionException:Connection refused:connect 是指客户端与服务端连接失败,可能是服务端没有启动,或者服务器端的端口号与客户端的不一致,或者服务器的防火墙拦截了客户端的请求。

    我这边是忘记的启动服务端

  • 相关阅读:
    【人工智能】基于八数码问题对比搜索算法的性能
    bpmn-process-designer基础上进行自定义样式(工具、元素、菜单)
    GZ033 大数据应用开发赛题第03套
    安装nodejs | npm报错
    git奇怪报错
    4. C++内存管理
    dubbo 用户指南
    KVM Cloud云平台
    Mac上安装Java的JDK多版本管理软件jEnv
    Spring Security OAuth2实现单点登录:简化多个系统之间的登录流程
  • 原文地址:https://blog.csdn.net/qq_31016939/article/details/138222322