Cannot Connect to Local Redis Instance: Invalid Host Name "localhost"
7 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Seth DeLand
on 24 Jan 2023
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 Comment
Nicole Bonfatti
on 1 Jun 2023
Edited: Nicole Bonfatti
on 1 Jun 2023
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 Also
Categories
Find more on RESTful API in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!