1. 문제

로컬 DB에 연결하려는데 connect ECONNREFUSED ::1:3306 에러가 떴다.

Screenshot 2023-11-18 at 12.35.50 PM.png

2. 해결 방법

::1은 ipv6의 localhost이다. 우리가 접속하려는 곳은 ipv4의 localhost인 127.0.0.1인데 말이다. 그래서, ::1을 제거해주어야 한다.

  1. sudo vim /private/etc/hosts

    Screenshot 2023-11-18 at 9.27.04 PM.png

  2. 위 처럼 Host Database가 나오는데, 위의 사진처럼 ::1 localhost에 주석 처리를 해주면 된다.

3. Reference

[nodejs]mySQL connect Error: connect ECONNREFUSED ::1:3306 이슈 해결