[Redis] Unable to connect to Redis : 로컬에 Redis init 시 config 파일 가져오기

 
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/127.0.0.1:6379 Unable to connect to Redis
 


 처음 초기화를 위해 install 한다

brew install redis


 

redis-server /usr/local/etc/redis.conf

 
위 명령어로 실행했을 때 실패하였고, redis 설정 파일문제라는 것을 알게 되었다. 올바른 설정 파일을 가져오기 위해

 brew --prefix redis

로 redis 파일의 경로를 알아내었다. (/opt/homebrew/opt/redis가 출력)
이후 이 설정 파일을 사용하여 Redis 서버를 시작한다.

 

 

redis-server /opt/homebrew/etc/redis.conf

 

를 출력하여 서버를 실행한다. 
 


cmd 창을 새로 켜고 redis-cli 명령어로 cli 에 접속한다.
ping을 입력하여 pong을 반환하는지 확인하였다.


 

 

$ brew services start redis
==> Successfully started `redis` (label: homebrew.mxcl.redis)

+ 명령어를 이용하여 redis가 시스템이 시작될 때마다 자동으로 시작되도록 하여 해결하였다.