I am deploying my NodeJS web application project in Microsoft azure. I am using Bitnami MongoDB vm for my server, the default port 27017 is not secured. Due to security reason I wanted to change some 27171, I have changed in mongo.conf file but its giving below error.
mongod.conf file-
dbpath=/data/db #where to log logpath=/opt/bitnami/mongodb/log/mongodb.log logappend=true #bind_ip = 127.0.0.1 port = 27171 journal=true # Turn on/off security. Off is currently the default #noauth = true auth = true
The error is
MongoDB shell version v3.4.0 connecting to: mongodb:///opt/bitnami/mongodb/tmp/mongodb-27017.sock/ 2017-04-03T13:07:48.437+0000 W NETWORK [main] Failed to connect to /opt/bitnami/mongodb/tmp/mongodb-27017.sock:0, reason: No such file or directory 2017-04-03T13:07:48.462+0000 E QUERY [main] Error: couldn't connect to server/opt/bitnami/mongodb/tmp/mongodb-27017.sock:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:234:13 @(connect):1:6 exception: connect failed
I have test in my lab, we can use this script to change the default port:
root@mongodb:/# mongod --port 49000 --dbpath /data/db
Here is the result:
root@mongodb:/data/db# mongo admin --username root -p ***** --port 49000
MongoDB shell version v3.4.2
connecting to: mongodb:///opt/bitnami/mongodb/tmp/mongodb-27017.sock/admin
MongoDB server version: 3.4.2
Server has startup warnings:
2017-04-04T05:20:58.801+0000 I STORAGE [initandlisten]
2017-04-04T05:20:58.801+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-04-04T05:20:58.801+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
> db = db.getSiblingDB('admin')
admin
>
>
>
I ran into the same problem, and just found the fix. The mongo
command isn't the normal mongo binary we have all come to love. It seems to be a custom one attempting to connect to the socket directly.
edit the custom mongo client script by running
$ sudo vim `which mongo`
Here is where they call the socket directly. Change the socket port and try running it again.
- /opt/bitnami/mongodb/tmp/mongodb-27017.sock + /opt/bitnami/mongodb/tmp/mongodb-27171.sock
Here is what mine looks like after editing:
#!/bin/sh
LC_ALL="C"
export LC_ALL
case "$@" in
*--host*)
exec $0.bin "$@"
exit
esac
exec $0.bin --host /opt/bitnami/mongodb/tmp/mongodb-28018.sock "$@"
Good Luck!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.