Hi. I have a very simple machine with only nginx, mongodb and nodejs installed. Everything works great on the first boot but when I "vagrant reload" my machine, I'm unable to connect to my mongo database. I get
- 2016-02-11T13:47:29.772+0000 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
- 2016-02-11T13:47:29.773+0000 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
- exception: connect failed
Anyone can help?
When opening the log here "/var/log/mongodb/mongodb.log"
I see these errors
2016-02-11T14:55:57.271+0000 ERROR: Cannot write pid file to /var/run/mongod.pid: Permission denied
2016-02-11T15:13:59.069+0000 ***** SERVER RESTARTED *****
2016-02-11T15:13:59.071+0000 ERROR: Cannot write pid file to /var/run/mongod.pid: Permission denied
2016-02-11T15:20:21.123+0000 ***** SERVER RESTARTED *****
2016-02-11T15:20:21.145+0000 ERROR: Cannot write pid file to /var/run/mongod.pid: Permission denied
I fixed it by updating the pidfilepath, in config.yaml:
mongodb:
install: '1'
settings:
bind_ip: '0.0.0.0'
port: '27017'
pidfilepath: '/tmp/mongod.pid'
Fixed as of latest release.
"ERROR: Cannot write pid file to /var/run/mongodb/mongod.pid: No such file or directory"
I tried this with a fresh centos 7 (64 bit) box and problem still exist with mongodb and mariadb. For some reason it only works after a provision and then stops working after a reload or restart. Only the workaround seems to be working is creating a .sh script to create the directory on every start with proper permissions. (https://github.com/puphpet/puphpet/issues/2458#issuecomment-252900977)
mkdir -p /var/run/mongodb/
chown mongod:mongod /var/run/mongodb/
chmod 0755 /var/run/mongodb/
systemctl start mongod.service
Possibly something to do with SELinux...
I'm using on Ubuntu 14.04, and still seeing this issue. The is built from scratch. I've uploaded my config once again, and re-downloaded and created everything from scratch.
After initial "vagrant up", I can connect to mongodb server, however after a "vagrant halt" and "vagrant up", I cannot access the mongodb server:
These are the mongodb parts of my config.yaml:
mongodb:
install: '1'
settings:
bind_ip: 127.0.0.1
port: '27017'
globals:
version: 2.6.0
databases:
mongodbnuad_blahblahblah:
name: stuff
user: stuff
password: stuff
nothing fancy as you can see.
And this is my log
2017-04-06T12:14:15.276+0300 [signalProcessingThread] shutdown: closing all files...
2017-04-06T12:14:15.277+0300 [signalProcessingThread] closeAllFiles() finished
2017-04-06T12:14:15.277+0300 [signalProcessingThread] journalCleanup...
2017-04-06T12:14:15.277+0300 [signalProcessingThread] removeJournalFiles
2017-04-06T12:14:15.285+0300 [signalProcessingThread] shutdown: removing fs lock...
2017-04-06T12:14:15.285+0300 [signalProcessingThread] dbexit: really exiting now
2017-04-06T12:18:00.613+0300 ***** SERVER RESTARTED *****
2017-04-06T12:18:00.644+0300 ERROR: Cannot write pid file to /var/run/mongod.pid: Permission denied
2017-04-06T12:24:55.201+0300 ***** SERVER RESTARTED *****
2017-04-06T12:24:55.203+0300 ERROR: Cannot write pid file to /var/run/mongod.pid: Permission denied
After "vagrant halt" , when I run "vagrant provision", I get this error:
==> stuffdev: Error: Facter: error while resolving custom fact "mongodb_is_master": 757: unexpected token at '2017-04-06T12:32:35.860+0300 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
==> stuffdev: 2017-04-06T12:32:35.861+0300 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146'
Adding pidfilepath didn't help on this case neither.
After adding pidfilepath trick as @thomaspicquet suggested, I've re-created the box, and after vagrant halt and vagrant up, I can see it's working nice.
@jtreminio - I'd appreciate if you could investigate this more. I'm stuck with Ubuntu 14.04 (not 16.04 due to #2461 ), and the newly downloaded puphpet.zip still gives me this issue.
Thanks in advance,
Same problem here
Most helpful comment
I fixed it by updating the pidfilepath, in config.yaml:
mongodb: install: '1' settings: bind_ip: '0.0.0.0' port: '27017' pidfilepath: '/tmp/mongod.pid'