재학습/오류

[Nodejs - Mongoose] MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster.

재삉 2021. 10. 6. 22:22
반응형

 

[배경]

MongoDB를 사용하기위해 MongoDB 공식 웹페이지의 Cluster를 사용하고자 했다. (https://www.mongodb.com/)

 

이번에도 마찬가지로 위의 예쁜코드를 사용했다.

*connect에 나오는 저 URL이 MongoDB Cluster를 생성하여 얻은 Connection String이다.

 

그러나..이번에도 결과는 참혹했다.

 

 

다음과 같은 오류가 나와버린 것..!

 

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:

 

[분석]

1.MongoDB Cluster의 DB에 Connect하지못했다.

2.현재 IP주소를 클러스터의 IP리스트에 추가해라.

 

으..응..알겠어 그렇게해볼게..!

그렇게 찾아낸 방법!

 

[해결]

1.MongoDB Cluster 웹페이지의 좌측탭에서 Network Access를 클릭한다.

 

 

2. 주황색 박스안에있는 Add IP Access버튼을 클릭하여 본인의 현재 IP주소를 입력한다.

3. 그 후 빨간색 박스에 Status가 Pending상태인데, 이 상태가 끝날때까지 기다려준다.

4.Status가 Active가 되면 모든준비는 끝난것이다.

그 후 실행을해보니 정상작동되는걸 확인할 수 있었다.

 

 

반응형