简体   繁体   English

Redis-连接被拒绝

[英]Redis - Connection refused

I am currently testing reading on Redis with a script PHP (with the driver predis). 我目前正在使用脚本PHP(使用驱动程序predis)对Redis进行阅读测试。

I have a client in which I make run the script with php-cli and a server where there is the database Redis. 我有一个使用php-cli运行脚本的客户端,以及一个有数据库Redis的服务器。

My problem : 我的问题 :

When I run the script, I have the message "connection refused" when excuting : 运行脚本时,执行时出现消息“连接被拒绝”:

if ($redis->exists($key)) {
    //processing...
}

Any ideas ? 有任何想法吗 ? thanks. 谢谢。

You want to make sure that you test the statements you use to access the database, prior to your script running them, that way you know they work. 您需要确保在脚本运行它们之前测试用于访问数据库的语句,以使它们知道它们的工作方式。 "Connection Refused" sounds like its not the line that you referenced in your post, but instead the connection string that is before it. “拒绝连接”听起来像不是您在帖子中引用的行,而是它前面的连接字符串。

You Need to start REDIS server. 您需要启动REDIS服务器。 because of sometime it is confused in port number and local host. 由于某个时间,它在端口号和本地主机中混淆了。 so if you got error "connection refused" then fire command like this : 因此,如果出现错误“连接被拒绝”,则执行以下命令:

nohup redis-server & 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM