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

Meteor应用本地自定义部署启动时遇MongoError连接拒绝问题求助

Fixing MongoError: ECONNREFUSED for Your Local Meteor Deployment

Hey there, let's work through this Mongo connection issue you're hitting when launching your Meteor app with Node. That ECONNREFUSED error tells us your app can't reach the MongoDB instance at 192.168.100.2:9001—here's how to troubleshoot and fix it:

1. Verify MongoDB is Running & Listening on the Correct Port/IP

First, make sure MongoDB is actually up and configured to listen on 192.168.100.2:9001:

  • Check if the port is being monitored with this command:
    ss -tulpn | grep 9001
    
    You should see an entry for mongod bound to 192.168.100.2:9001.
  • If MongoDB isn't running, start it with your system's service manager (e.g., sudo systemctl start mongod).
  • If it's running but not on the right IP/port, edit your MongoDB config file (usually /etc/mongod.conf):
    • Update the port field to 9001
    • Set bindIp to 192.168.100.2 (or 0.0.0.0 to allow all IPs for testing)
    • Restart MongoDB: sudo systemctl restart mongod

2. Ensure Your Meteor App Uses the Correct MONGO_URL

Meteor relies on the MONGO_URL environment variable to connect to MongoDB. Double-check you're setting it properly when launching the app:

  • Launch your app with the correct connection string (replace your-db-name with your actual database name):
    MONGO_URL="mongodb://192.168.100.2:9001/your-db-name" node main.js
    
  • If you're using a settings.json file, confirm the MongoDB configuration inside matches the IP/port of your running instance.

3. Test Network Connectivity Between Your App & MongoDB

Even if MongoDB is running, network issues might block the connection:

  • Ping the MongoDB server from your app's machine to confirm basic connectivity:
    ping 192.168.100.2
    
  • Test if the port is accessible with nc (netcat):
    nc -zv 192.168.100.2 9001
    
    If this fails, check your firewall rules—you'll need to allow inbound traffic on port 9001 for 192.168.100.2.

4. Check MongoDB Authentication (If Enabled)

If your MongoDB instance requires a username and password, make sure MONGO_URL includes the auth details:

MONGO_URL="mongodb://your-username:your-password@192.168.100.2:9001/your-db-name?authSource=admin" node main.js

Ensure the user has read/write permissions for your target database.

5. Try Localhost for Same-Machine Deployments

If MongoDB is running on the same machine as your Meteor app, sometimes using localhost instead of the internal IP can resolve binding issues:

MONGO_URL="mongodb://localhost:9001/your-db-name" node main.js

If this works, it means MongoDB is only listening on localhost—update its bindIp config to include 192.168.100.2 as mentioned earlier.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 04:24:28