Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused (Connection refused)


一、linux中配置redis,使用java連接測試時報錯:

Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused (Connection refused)

原因:

linux中的防火牆沒有關閉,在終端中輸入以下命令關閉防火牆即可:

1) Linux操作系統中永久性生效,重啟后不會復原

開啟: chkconfig iptables on

關閉: chkconfig iptables off

2) 即時生效,重啟后復原

開啟: service iptables start

關閉: service iptables stop

 

二、centos7的一些變化,firewalld替換iptables、systemctl 替換service

1.防火牆命令用firewalld取代了iptables了。

 

查看防火牆狀態   systemctl status firewalld

 

臨時關閉防火牆命令,reboot之后,防火牆自動起來。   systemctl stop firewalld

 

永久關閉防火牆命令。reboot之后,防火牆不會自動啟動    systemctl disable firewalld

 

啟動防火牆命令   systemctl enable firewalld

2.用systemctl 代替了service,不過為了向后兼容,centos7中,service還是可以用的。

如使用systemctl關閉防火牆

systemctl stop firewalld.service


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM