Java java.net.ConnectException:连接被拒绝 [英] Java java.net.ConnectException: Connection refused

查看:184
本文介绍了Java java.net.ConnectException:连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将应用程序复制到服务器时遇到问题。
程序在我的测试机器(Mac OS X)上正常运行,但是当我在我的服务器(Windows Server 2008)上部署它时,我收到以下错误:

I'm having an issue when copying my application to the server. The program runs fine on my testing machine (Mac OS X), but when I deploy it on my server (Windows Server 2008), I get the following error:


java.net.ConnectException:拒绝连接

java.net.ConnectException: Connection refused

我确定我已打开正确用于出站连接的端口。只是80端口?

I'm sure I've open the ports correctly for outbound connections. Just port 80 right?

这是一个代码片段,如果有帮助

Here's a code snippet if it helps

try {
    doc = Jsoup.connect("http://google.com").get();
} catch (IOException e) {
    e.printStackTrace();
    return;
}

Java不是我的主要语言,所以让我知道是否还有更多你需要。

Java isn't my main language, so let me know if there's anything more you need.

推荐答案

由于以下两个原因之一,这个问题几乎总是出现:

1)服务器没有在正确的端口上侦听

2)你有防火墙可以阻止交通

This problem almost always came up because of one of two reasons:
1) The server is not listening on right port
2) You have firewall which blocks out trafic

尝试暂时停止防火墙,看看发生了什么。

Try to stop your firewall temporarily and see what's going on.

这篇关于Java java.net.ConnectException:连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆