connect ECONNREFUSED ::1:8011
时间: 2023-09-04 21:09:18 浏览: 158
该错误意味着您的程序试图连接到地址::1,这是一个IPv6地址,对应于localhost。然而,MongoDB并没有在IPv6地址上监听,而只在IPv4地址(即127.0.0.1)上监听。解决方案是在连接字符串中明确使用IPv4的地址。将原来的连接字符串中的localhost改为127.0.0.1即可解决该问题。例如,将mongoose.connect('mongodb://localhost:27017/d', { useNewUrlParser: true, useUnifiedTopology: true }) 改为mongoose.connect('mongodb://127.0.0.1:27017/d', { useNewUrlParser: true, useUnifiedTopology: true })。这样您的程序应该能够成功连接到MongoDB数据库了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [MongoDB报错 Could not connect to MongoDB MongooseServerSelectionError: connect ECONNREFUSED ::1:...](https://blog.csdn.net/qq_45311632/article/details/131360963)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [解决Node.js使用MySQL出现connect ECONNREFUSED 127.0.0.1:3306的问题](https://download.csdn.net/download/weixin_38712279/12976872)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文