[英]REDIS php extension connect error
When I use redis PHP extension, I get the error, the host is 127.0.0.1 and the port is 6379. 当我使用redis PHP扩展时,出现错误,主机是127.0.0.1,端口是6379。
Redis::connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known.
Redis :: connect():php_network_getaddresses:getaddrinfo失败:名称或服务未知。
I had the same issue happening sporadically on my local server with a number of attempted fixes yielding no resolution. 我在本地服务器上偶发地发生了同样的问题,尝试了许多修复程序,但均未解决。 This post here gave me an idea that seems to have finally fixed the problem.
这篇文章给了我一个想法,似乎终于解决了这个问题。
Basically, I have a number of vhosts set up on my local machine (running Ubuntu) which allows me to use domain names to access locally-run sites instead of the usual 'localhost/sitename' approach. 基本上,我在本地计算机(运行Ubuntu)上设置了多个虚拟主机,这使我可以使用域名访问本地运行的站点,而不是通常的“ localhost / sitename”方法。 As a result, I had no IP assigned to 'localhost' name.
结果,我没有将IP分配给“ localhost”名称。
This might not be the same root cause for the problem for you, but here's how I've solved mine: 这可能不是造成您问题的根本原因,但以下是我解决问题的方法:
Of course, as a sanity check, make sure your redis-server is up and running, try rebooting Apache in case you've made any config changes, etc. 当然,作为健全性检查,请确保您的redis服务器已启动并正在运行,并尝试重新启动Apache,以防万一您进行了任何配置更改,等等。
In my case, the issue was simple; 就我而言,问题很简单。 the host name was incorrectly typed.
主机名输入错误。
To find out the exact issue, I had to do the following in my console: 为了找出确切的问题,我必须在控制台中执行以下操作:
ping <host-name>
or if you have redis-cli installed, you can just call that from the console as such: 或者如果您已安装redis-cli,则可以从控制台这样调用它:
redis-cli -h <host-name> -p <port-number> -a <auth-pass>
For mac users: 对于Mac用户:
Open terminal and try this command: 打开终端并尝试以下命令:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.