에러
/home/cloudcoke/my/nodejs/221222_2/node_modules/mysql2/promise.js:341
const localErr = new Error();
^
Error: connect ECONNREFUSED 127.0.0.1:3306
at PromisePool.query (/home/cloudcoke/my/nodejs/221222_2/node_modules/mysql2/promise.js:341:22)
at exports.findAll (/home/cloudcoke/my/nodejs/221222_2/repository/board.repository.js:4:31)
at exports.getList (/home/cloudcoke/my/nodejs/221222_2/services/board.service.js:4:30)
at exports.list (/home/cloudcoke/my/nodejs/221222_2/controller/board.controller.js:4:30)
at Layer.handle [as handle_request] (/home/cloudcoke/my/nodejs/221222_2/node_modules/express/lib/router/layer.js:95:5)
at next (/home/cloudcoke/my/nodejs/221222_2/node_modules/express/lib/router/route.js:144:13)
at Route.dispatch (/home/cloudcoke/my/nodejs/221222_2/node_modules/express/lib/router/route.js:114:3)
at Layer.handle [as handle_request] (/home/cloudcoke/my/nodejs/221222_2/node_modules/express/lib/router/layer.js:95:5)
at /home/cloudcoke/my/nodejs/221222_2/node_modules/express/lib/router/index.js:284:15
at Function.process_params (/home/cloudcoke/my/nodejs/221222_2/node_modules/express/lib/router/index.js:346:12) {
code: 'ECONNREFUSED',
errno: -111,
sql: undefined,
sqlState: undefined,
sqlMessage: undefined
}
Node.js v18.12.1
원인
- node.js에서 mysql과 통신하는 코드를 작성하고 실행 시킨 후 에러가 발생했다.
해결
- mysql 서버가 켜져있지 않아서 켜주었더니 해결이 되었다.
sudo service mysql start
netstat -lntup |grep 3306