에러 배경
'docker에서 mariadb를 실행하고 mysql workbench에 연결하는 과정'
+
'node.js를 이용해 docker의 mariadb를 연동하는 과정'
에러 그 잡채
workbench를 연결하는 과정에서 port number를 연결하는 과정에서 실패


추가적으로 mariadb의 문제가 있나 확인을 위해 기존에 잘 연동되었던 프로젝트를 실행해 보니 여기도 마찬가지로 에러 발생
node:events:496
throw er; // Unhandled 'error' event
^
AggregateError [ECONNREFUSED]:
at internalConnectMultiple (node:net:1116:18)
at afterConnectMultiple (node:net:1683:7)
--------------------
at Protocol._enqueue (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Protocol.handshake (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\protocol\Protocol.js:51:23)
at Connection.connect (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\Connection.js:116:18)
at Object.<anonymous> (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\index.js:6:9)
at Module._compile (node:internal/modules/cjs/loader:1369:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Module._load (node:internal/modules/cjs/loader:1022:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49
Emitted 'error' event on Connection instance at:
at Connection._handleProtocolError (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\Connection.js:423:8)
at Protocol.emit (node:events:518:28)
at Protocol._delegateError (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\protocol\Protocol.js:398:10)
at Handshake.<anonymous> (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\protocol\Protocol.js:153:12)
at Handshake.emit (node:events:518:28)
at Sequence.end (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\protocol\sequences\Sequence.js:78:12)
at Protocol.handleNetworkError (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\protocol\Protocol.js:369:14)
at Connection._handleNetworkError (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\Connection.js:418:18)
at Socket.emit (node:events:518:28)
at emitErrorNT (node:internal/streams/destroy:169:8) {
code: 'ECONNREFUSED',
fatal: true,
[errors]: [
Error: connect ECONNREFUSED ::1:3306
at createConnectionError (node:net:1646:14)
at afterConnectMultiple (node:net:1676:16) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 3306
},
Error: connect ECONNREFUSED 127.0.0.1:3306
at createConnectionError (node:net:1646:14)
at afterConnectMultiple (node:net:1676:16) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306
}
]
}
Node.js v20.12.2
해결 과정
해결 과정은 위 두 가지 문제인 nodejs의 연동과 workbench 연동 모두 테스트해 봤다.
시도1. 컨테이너 종료 후 재실행
가장 쉬운 docker desktop을 종료했다가 다시 실행해 보았지만 nodejs, workbench 모두 실패...
시도2. 연결하는 host를 localhost → 127.0.0.1로 변경
많은 사람들이 이렇게 고치고 다 해결했는데 왜 나만... nodejs에서 변화가 있었지만 에러 메시지가 조금 짧아질 뿐 실패...
node:events:496
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 127.0.0.1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16)
--------------------
at Protocol._enqueue (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Protocol.handshake (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\protocol\Protocol.js:51:23)
at Connection.connect (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\Connection.js:116:18)
at Object.<anonymous> (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\index.js:6:9)
at Module._compile (node:internal/modules/cjs/loader:1369:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Module._load (node:internal/modules/cjs/loader:1022:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49
Emitted 'error' event on Connection instance at:
at Connection._handleProtocolError (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\Connection.js:423:8)
at Protocol.emit (node:events:518:28)
at Protocol._delegateError (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\protocol\Protocol.js:398:10)
at Handshake.<anonymous> (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\protocol\Protocol.js:153:12)
at Handshake.emit (node:events:518:28)
at Sequence.end (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\protocol\sequences\Sequence.js:78:12)
at Protocol.handleNetworkError (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\protocol\Protocol.js:369:14)
at Connection._handleNetworkError (C:\Users\User\Desktop\TY\다른 컴퓨터\ProgrammersSchool\TRAIN-TENNISMARKET\node_modules\mysql\lib\Connection.js:418:18)
at Socket.emit (node:events:518:28)
at emitErrorNT (node:internal/streams/destroy:169:8) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true
}
Node.js v20.12.2
시도3. 컨테이너 삭제 후 port 번호를 바꿔서 재생성
진짜 하기 싫은 시도였지만 컨테이너를 지우고 port 번호가 문제일 수도 있으니 3306 → 3307로 바꿔서 시도했지만 실패...
오히려 docker desktop에서 에러 메시지 생성...

해결. tcp 프로세스 종료 후 재실행
여러 방법을 찾던 중 진짜 뜬금없이 cmd에서 tcp 프로세스를 종료했다가 켰는데 됐다고 해서 나도 시도해 봤는데... 기가 막히게 성공!
// cmd에서 실행
net stop winnat // 프로세스 종료
net start winnat // 프로세스 실행

정리
결국 윈도우가 뭔가 이상이 있었던 것 같다. 다음에는 컨테이너 삭제 전에 시도할 수 있는 다른 부분들을 먼저 찾아서 시도할 수 있기를 바랄 뿐이다... 컨테이너 삭제하고 테이블 생성하는데 너무 스트레스🤢였다. 그래도 결국 해결해서 기분이 좋은가? 좋다...
'에러' 카테고리의 다른 글
| [Node.js ERR_HTTP_HEADERS_SENT 에러] 헤더를 세팅하지 말라고? (0) | 2024.05.20 |
|---|---|
| [mariadb 1175 에러] 업데이트하는데 키를 이용하라고? (0) | 2024.05.09 |
| [npm install 에러] package.json, package-lock.json, node_modules 어디갔어? (0) | 2024.04.22 |
| [css 에러]display:inline, inline-block 생긴거 왜 이래? 여백이 생기네 (0) | 2023.11.10 |
| [쿠키 에러]쿠키 왔는데 저장을 못하니? SameSite 이슈 (0) | 2023.10.12 |