• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

already in use에러

21.06.08 13:36 작성 조회수 220

0

Error: listen EADDRINUSE: address already in use :::4000

4000포트 사용하는 PID를 kill한 후 다시 start로 올려도 동일한 에러가 발생합니다.

작성한 구문은 아래에 첨부합니다.

const port = 4000 // 포트

const mongoose = require('mongoose')
mongoose.connect('mongodb+srv://kyungwon:abcd1234@boilerplate.dg2la.mongodb.net/boilerplate?retryWrites=true&w=majority', {
useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false
}).then(() => console.log('MongoDB Connected...'))
.catch(err => console.log(err))

답변 2

·

답변을 작성해보세요.

1

황경원님의 프로필

황경원

질문자

2021.06.08

이게 효과 있는건지 모르겠는데 vscode를 아예 종료했다가 다시 실행해서 올려보니 정상적으로 연결 되었습니다.

0

황경원님의 프로필

황경원

질문자

2021.06.08

vscode를 재실행 한 후에는 위와같은 오류가 발생하지 않고 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.

이런 오류가 발생하고 있습니다. 참고로 ip를 몽고db에 설저해두었고, 모든 ip대상으로 설정하여도 마찬가지 입니다.

환경은 맥입니다.