You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows10运行Node.js连接MongoDB报MongoNetworkError求助

Fixing MongoNetworkError: connect ETIMEDOUT on Windows 10

Hey there, since your code runs fine on other machines, this connection timeout issue is almost certainly tied to your new Windows 10 environment's network or MongoDB setup. Let's walk through the most likely fixes:

  • Verify MongoDB Service is Running
    On Windows, MongoDB typically runs as a Windows service. Hit Win + R, type services.msc, and look for the service named MongoDB Server (or similar). If it's stopped, right-click it and select "Start". For future reliability, set its startup type to "Automatic" so it launches with your system.

  • Double-Check Your Connection String Details
    The error shows you're trying to connect to 10.237.141.117:27011. Ask yourself:

    • Is this the correct IP/port for your MongoDB instance? If it's a local instance, you should be using localhost or 127.0.0.1 instead of that 10.x.x.x private network address.
    • If it's a remote MongoDB instance, confirm:
      1. The remote server's firewall allows inbound traffic on port 27011 from your Windows 10 machine's IP.
      2. Your Windows Defender Firewall allows outbound traffic to that port and IP.
  • Test Port Connectivity
    Use PowerShell to test if your machine can reach the target IP and port. Run this command:

    Test-NetConnection 10.237.141.117 -Port 27011
    

    If the result shows "TcpTestSucceeded: False", that confirms a network-level block—either the port isn't open, the MongoDB instance isn't listening on it, or a firewall is blocking the connection.

  • Check MongoDB's Listening Port & Bind IP
    Open your MongoDB configuration file (usually mongod.cfg in C:\Program Files\MongoDB\Server\<version>\bin):

    • Look for the net.port setting—ensure it matches the port in your connection string (27011). The default port is 27017, so if you didn't change it, you might have a typo in your code.
    • Check the net.bindIp setting. If connecting remotely, set it to 0.0.0.0 (allow all IPs) or the server's specific IP. For local connections, 127.0.0.1 works, just make sure your connection string uses that IP.
  • Temporarily Disable Firewall for Testing
    As a quick diagnostic step, temporarily turn off Windows Defender Firewall (go to Control Panel > System and Security > Windows Defender Firewall > Turn Windows Defender Firewall on or off). If your app connects successfully after this, add a permanent firewall rule to allow traffic to/from your MongoDB port.


内容的提问来源于stack exchange,提问作者Akhil Kintali

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 06:46:14