ljlm0402 / typescript-express-starter

📘 Quick and Easy TypeScript Express Starter
http://npm.im/typescript-express-starter
MIT License
2.72k stars 419 forks source link

Node 17 causes app to crash due to connection error for Mongoose #158

Open julschong opened 2 years ago

julschong commented 2 years ago

Hi there,

This is a minor issue that has a solution posted below.

Describe the Bug (버그 설명)

I used the mongoose template and it would start up the server but crashed within 20 secs. And no error message is shown on the terminal. After looking into the log, it shows: 2022-04-12 02:19:48 error: uncaughtException: connect ECONNREFUSED ::1:27017 MongooseServerSelectionError: connect ECONNREFUSED ::1:27017

Version to Reproduce (현재 사용한 버전)

typescript-express-starter@8.1.7

Steps to Reproduce (재현 순서)

  1. nvm use 17 or use node version 17
  2. npx typescript-express-starter test
  3. choose mongoose
  4. cd test
  5. npm run dev
  6. App crash

Expected Behavior (예상 동작)

Server start without crashing

Actual Behavior (실제 동작)

Server crashes within 20 secs, logs 2022-04-12 02:19:48 error: uncaughtException: connect ECONNREFUSED ::1:27017 MongooseServerSelectionError: connect ECONNREFUSED ::1:27017

Additional Context (추가 사항)

Confirmed that node 17 is the cause of this. Here is the thread I found about this: https://www.mongodb.com/community/forums/t/mongooseserverselectionerror-connect-econnrefused-127-0-0-1-27017/123421

I tested and confirmed:

Capture screen (캡쳐 화면)

image

main95 commented 2 years ago

As in the issue https://github.com/ljlm0402/typescript-express-starter/issues/117, another solution is that try to change the DB_HOST variable to mongo in the configuration file .env.development.local

jacoblsdev commented 5 months ago

I changed port and DB_NAME, it solved my issue.