(node:1129) UnhandledPromiseRejectionWarning: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
    at NativeConnection.Connection.openUri (/workspace/webdevbootcamp/YelpCamp/v3/node_modules/mongoose/lib/connection.js:800:32)
    at cb (/workspace/webdevbootcamp/YelpCamp/v3/node_modules/mongoose/lib/index.js:341:10)
    at Promise (/workspace/webdevbootcamp/YelpCamp/v3/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:5)
    at new Promise (<anonymous>)
    at promiseOrCallback (/workspace/webdevbootcamp/YelpCamp/v3/node_modules/mongoose/lib/helpers/promiseOrCallback.js:30:10)
    at Mongoose.connect (/workspace/webdevbootcamp/YelpCamp/v3/node_modules/mongoose/lib/index.js:340:10)
    at Object.<anonymous> (/workspace/webdevbootcamp/YelpCamp/v3/app.js:9:10)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
(node:1129) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by reje
cting a promise which was not handled with .catch(). (rejection id: 1)

 

데이터를 불러올 mongodb와 연결에 문제가 있을 경우 발생한다.

1. mongodb가 실행되어 있는지 확인
mongdb 실행 명령어: mongod

2. mongoose와 mongodb connection을 확인한다. 기본 포트는 27017이다.

// mongodb와 mongoose 연결하여 js로 mongodb 사용 가능하게 설정한다. 27017은 mongodb의 기본 포트
mongoose.connect("mongodb://localhost:27017/yelp_camp", {useNewUrlParser: true, useUnifiedTopology: true});

+ Recent posts