码迷,mamicode.com
首页 > 系统相关 > 详细

Linux下防火墙开启相关端口及查看已开启端口

时间:2014-12-12 18:27:40      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   os   sp   java   on   

Exception in thread "main" org.apache.http.conn.HttpHostConnectException: Connection to http://10.5.20.96:8011 refused
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:190)
    at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:640)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1066)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1044)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1035)
    at com.tudou.findlabel.entrance.ClientWithResponseHandler.main(ClientWithResponseHandler.java:52)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:127)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
    ... 8 more
原来是因为linux下没有开启对8011的端口访问权限造成的。通过下面的命令可以开启允许对外访问的网络端口:

/sbin/iptables -I INPUT -p tcp --dport 8011 -j ACCEPT #开启8011端口 
/etc/rc.d/init.d/iptables save #保存配置 
/etc/rc.d/init.d/iptables restart #重启服务 
查看端口是否已经开放
/etc/init.d/iptables status 
结果如下 

bubuko.com,布布扣

Linux下防火墙开启相关端口及查看已开启端口

标签:style   blog   http   io   ar   os   sp   java   on   

原文地址:http://www.cnblogs.com/Ivan-j2ee/p/4159981.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!