• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

db connectio 에러

21.07.24 14:41 작성 조회수 167

0

DB 연결에서 계속 오류가 나요

에러 메시지 보고 cmd 창에서 ip 보고 mongoDB network access 에서 ip 수정하고 다시 이전꺼랑 해서 새로 추가했는데 동일하게 오류가 나와요

확인 부탁드립니다 ㅜㅜ

PS D:\nodeJs\models> npm run start

> nodejs@1.0.0 start D:\nodeJs

> node index.js

Example app listening at http://localhost:5100

MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/

    at NativeConnection.Connection.openUri (D:\nodeJs\node_modules\mongoose\lib\connection.js:846:32)

    at D:\nodeJs\node_modules\mongoose\lib\index.js:351:10

    at D:\nodeJs\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5

    at new Promise (<anonymous>)

    at promiseOrCallback (D:\nodeJs\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10)

    at Mongoose._promiseOrCallback (D:\nodeJs\node_modules\mongoose\lib\index.js:1149:10)

    at Mongoose.connect (D:\nodeJs\node_modules\mongoose\lib\index.js:350:20)

    at Object.<anonymous> (D:\nodeJs\index.js:14:10)

    at Module._compile (internal/modules/cjs/loader.js:1251:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)

    at Module.load (internal/modules/cjs/loader.js:1100:32)

    at Function.Module._load (internal/modules/cjs/loader.js:962:14)

    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)

    at internal/main/run_main_module.js:17:47 {

  reason: TopologyDescription {

    type: 'ReplicaSetNoPrimary',

    setName: null,

    maxSetVersion: null,

    maxElectionId: null,

    servers: Map(3) {

      'wwwpyk-shard-00-01.7lopm.mongodb.net:27017' => [ServerDescription],

      'wwwpyk-shard-00-02.7lopm.mongodb.net:27017' => [ServerDescription],

      'wwwpyk-shard-00-00.7lopm.mongodb.net:27017' => [ServerDescription]

    },

    stale: false,

    compatible: true,

    compatibilityError: null,

    logicalSessionTimeoutMinutes: null,

    heartbeatFrequencyMS: 10000,

    localThresholdMS: 15,

    commonWireVersion: null

  }

}

답변 1

답변을 작성해보세요.

0

푸르님의 프로필

푸르

2021.11.11

터미널창에 ipconfig 입력해 ipv4의 ip주소를 혹시 적으셨나요? 그거 말고 공인 IP를 입력해야 되더라구요. 공인 IP는 네이버에 "내 ip 주소 확인" 이나 mongoDB > network access > 새 ip 추가하실 때 왼쪽 상단에 current ip address 누르면 나옵니다! 도움이 되시면 좋겠네요. 

반바지 (-BanBaZy)님의 프로필

반바지 (-BanBaZy)

2022.03.08

같은 에러로 골치 아팠었는데 덕분에 해결했습니다. 정말 감사합니다.