注册 登录
编程论坛 JAVA论坛

求java.net.ConnectException: Connection refused: connect具体解决方法

colorfulwolf 发布于 2018-03-28 20:27, 6910 次点击
Connection refused: connect具体解决方法,谢谢
8 回复
#2
chenxinghui2018-04-11 14:12
重启一下项目,
#3
疯狂的小a2018-04-12 19:08
问题能具体一点吗....你要连接什么
#4
colorfulwolf2018-04-14 13:01
回复 3楼 疯狂的小a
import
import
import
import
import
import
import
import

public class URLReader {

    public static void main(String[] args) throws IOException {
        
             InetAddress address = InetAddress.getByName("localhost");
             Socket s = new Socket(address, 8080);  //向服务器侦听端口发出请求
             System.out.println("客户端已启动。");
    }
}

编译后提示
Exception in thread "main" Connection refused: connect
    at (Native Method)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at (Unknown Source)
    at URLReader.main(URLReader.java:15)

#5
colorfulwolf2018-04-14 13:02
回复 2楼 chenxinghui
重启有用的话我就不在这问了。谢谢你的回复
#6
疯狂的小a2018-04-14 13:58
是不是服务器没有启动
#7
疯狂的小a2018-04-14 13:59
你直接在浏览器输入localhost:8080看看能不能访问
#8
colorfulwolf2018-04-14 14:08
回复 7楼 疯狂的小a

#9
北狗2020-06-15 17:14
后来解决了吗??
1