[Mongoose] Could not connect to any servers in your MongoDB Atlas cluster. 오류 해결
2024. 9. 5. 20:42ㆍ카테고리 없음
MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster.
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://www.mongodb.com/docs/atlas/security-whitelist/
at _handleConnectionErrors (/node_modules/mongoose/lib/connection.js:897:11)
at NativeConnection.asPromise (/node_modules/mongoose/lib/connection.js:1360:11) {
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
servers: Map(3) {
생략
},
stale: false,
compatible: true,
},
갑자기 npm run dev를 하니까 잘 연결되던 db 연동이 끊겨진 것이다..
그래서 급히 구글링해보니까 설정된 IP주소가 달라서 생기는 문제였다.
MongoDB site -> Security -> Network access 에서 현재PC의 IP를 직접 추가하면된다!
하지만 추가했음에도 똑같은 오류..
IP에 관계 없이 접속을 허용해주게끔 0.0.0.0/0 IP를 등록하고 나니 바로 해결됐다.