Cannot Connect to Local Redis Instance: Invalid Host Name "localhost"

7 次查看(过去 30 天)
Hi everyone,
I'm trying to get started with connecting MATLAB to a local Redis data cache instance. I've followed the basic example in the mps documentation but I've been getting the following error:
I'm on Mac OS Catalina 10.15.7. I've installed Redis via homebrew and was able to connect successfully from the command line (successful ping-pong output), including creating the sever with "-h localhost" and port #6379.
I don't really understand what's going on. Am I supposed to start the server from the command line first and then MATLAB connects to it, or does mps.cache.control create it? Does being on Mac require more setup first? Am I supposed to create the data cache with a specific configuration using the mps command line tools first (which I couldn't try because I couldn't find the path for the CLI code)?
Sorry if these are newbie questions, but I haven't really found anything that appears to be related yet in the documentation or online. Any other resources would be appreciated!

回答(1 个)

Seth DeLand
Seth DeLand 2023-1-24
I encountered this same message, for me the problem was that my /etc/hosts file on MacOS had been modified when I did some work with docker/kubernetes. By default, that file has the following 3 lines:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
Mine had this additional line that was uncommented:
127.0.0.1 kubernetes.docker.internal
When I commented out that line above (with a "#" sign) and saved the file, I was able to start the Redis cache from MATLAB.
  1 个评论
Nicole Bonfatti
Nicole Bonfatti 2023-6-1
编辑:Nicole Bonfatti 2023-6-1
if you still want that "kubernetes.docker.internal" hostname to resolve, after commenting it out you can add it to the end of the first "localhost" line. IE:
127.0.0.1 localhost kubernetes.docker.internal
See: The wikipedia entry for the hosts file.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 RESTful API 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by