코드코코

[리눅스] [MariaDB] ConnectionRefusedError [SequelizeConnectionRefusedError]: connect ECONNREFUSED 127.0.0.1:3306 본문

기록/정리

[리눅스] [MariaDB] ConnectionRefusedError [SequelizeConnectionRefusedError]: connect ECONNREFUSED 127.0.0.1:3306

코드코코 2021. 12. 21. 16:41

현재상황

- sequelize 로 mariadb(3307 포트) 연결하려고 함 

- yarn start 를 통해 서버 여는 중에 웹서버 5000 포트 열기 성공

- mariadb 연결 에러로 실패

 

에러 내용

ConnectionRefusedError [SequelizeConnectionRefusedError]: connect ECONNREFUSED 127.0.0.1:3306
at ConnectionManager.connect (/home/ubuntu/workspace/login/server/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:116:17)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async ConnectionManager._connect (/home/ubuntu/workspace/login/server/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:318:24)
at async /home/ubuntu/workspace/login/server/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:250:32
at async ConnectionManager.getConnection (/home/ubuntu/workspace/login/server/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:280:7)
at async /home/ubuntu/workspace/login/server/node_modules/sequelize/lib/sequelize.js:620:26
at async MySQLQueryInterface.createTable (/home/ubuntu/workspace/login/server/node_modules/sequelize/lib/dialects/abstract/query-interface.js:225:12)
at async Function.sync (/home/ubuntu/workspace/login/server/node_modules/sequelize/lib/model.js:1299:5)
at async Sequelize.sync (/home/ubuntu/workspace/login/server/node_modules/sequelize/lib/sequelize.js:800:35) {
parent: Error: connect ECONNREFUSED 127.0.0.1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true
},
original: Error: connect ECONNREFUSED 127.0.0.1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true
}
}

에러원인

- Sequelize를 사용하는데 MySQL의 포트를 지정해주지 않아서 기본 포트인 3306을 인식하여 윈도우용을 잡아 연결이 되지 않음.

 

해결방법

- config/config.json 파일에 port 설정을 추가

port 3307 설정 추가

 

DB 연결 성공