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

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 日

0 投票

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.

サインインしてコメントする。

カテゴリ

製品

リリース

R2020b

タグ

質問済み:

2022 年 1 月 30 日

編集済み:

2023 年 6 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by