JS/JS, TS 학습기록

[MongoDB] 몽고디비 연결안됨 에러: UnhandledPromiseRejectionWarning, DeprecationWarning

kth990303 2021. 6. 21. 16:03
반응형

카페에서 nodejs 공부하고 몽고디비를 연결하여 테스트해보려던 중 아래 에러가 발생했다.

(node:2484) UnhandledPromiseRejectionWarning: ReferenceError: err is not defined
    at C:\Users\User\Desktop\web_workspace\boiler_plate\index.js:22:17
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)   
(node:2484) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js pro

(node:2484) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js pro


해결방법

허용되지 않은 IP에서 몽고디비 클러스터에 연결하려 했기 때문에 발생한 에러였다.

나는 대부분 집에서 작업을 하는데, 카공하려고 카페에 왔기 때문에 IP가 바껴 발생한 에러였다.

모든 아이피를 허용해주는 0.0.0.0/0 을 ADD IP ADDRESS를 클릭해 허용시켜주었더니 해결됐다.

반응형