By haoruzhao
Hi Guys, I have one question that i saw the error in my docker droplet(ip is 104.131.114.98) like, any thing else to make it work? Thank you:
/opt/reaction/dist/bundle/programs/server/node_modules/fibers/future.js:313
throw(ex);
^
**MongoError: failed to connect to server [104.236.41.77:27017] on first connect**
at Object.Future.wait (/opt/reaction/dist/bundle/programs/server/node_modules/fibers/future.js:449:15)
at new MongoConnection (packages/mongo/mongo_driver.js:211:27)
Can not figure why this happens. my mongodb droplet (ip is 104.236.41.77 ) ufw config is:
To Action From
-- ------ ----
22 ALLOW Anywhere
80 ALLOW Anywhere
443 ALLOW Anywhere
Anywhere ALLOW 104.131.114.98
27017 ALLOW Anywhere
22 (v6) ALLOW Anywhere (v6)
80 (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)
27017 (v6) ALLOW Anywhere (v6)
my mongodb configure is:
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 104.236.41.77
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I have somewhat limited experience with Docker as I much prefer to stick with bare metal or the hypervisor layer (KVM for DigitalOcean), though from that experience, Docker doesn’t bind to a specific IP, IIRC. So connecting to a MongoDB instance that is within a container wouldn’t normally be possible from the Droplet’s public IP by default.
You’d have to setup port forwarding using iptables and forward requests on the host (Droplet) to the container (where MongoDB is) – such as accepting requests on port 27017 (on the Droplet) and then forwarding it to the exposed port on the container (which could be the same port).
You may have the port open on the host (Droplet), but that doesn’t generally translate to a container picking up the connection unless the firewall is configured to forward the request to a specific container. When a request is received, the host node (Droplet) doesn’t have anything running on that port and without the firewall, can’t route accordingly.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.