java用的jedis连接redis。reids是安装在虚拟机里面,ip是192.168.216.128,在本地能ping通虚拟机,并且xshell也能远程登录虚拟机。虚拟机内的redis服务正常,可以启动,并且执行命令没问题。问题:在虚拟机外telnet+端口号连得上虚拟机而java连接却连不上redis。异常信息:Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect at redis.clients.jedis.Connection.connect(Connection.java:134) at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:69) at redis.clients.jedis.Connection.sendCommand(Connection.java:79) at redis.clients.jedis.Connection.sendCommand(Connection.java:75) at redis.clients.jedis.BinaryClient.auth(BinaryClient.java:499) at redis.clients.jedis.Jedis.auth(Jedis.java:1963) at com.liyh.web.JedisDemo.test1(JedisDemo.java:13) at com.liyh.web.JedisDemo.main(JedisDemo.java:188)Caused by: java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:529) at redis.clients.jedis.Connection.connect(Connection.java:129)连接不上,不知道为什么连接不上,谁知道还请告知,谢谢!
关闭linux上的防火墙就行了