I am following a 'Web Dev Simplified' tutorial using AWS-Cloud9 Ubuntu environment. Everything was going well until I had to connect to the mongodb. The db seemed to install fine with...
sudo apt install -y mongodb
and is running.
ubuntu:~/environment $ sudo systemctl status mongodb
● mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-06-11 13:19:28 UTC; 20min ago
Docs: man:mongod(1)
Main PID: 17781 (mongod)
Tasks: 23 (limit: 1152)
CGroup: /system.slice/mongodb.service
└─17781 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc/mongodb.conf
Jun 11 13:19:28 ip-172-31-16-249 systemd[1]: Started An object/document-oriented database.
The tutorial uses mongoose and throws an error on connect. Here is the connection string
mongoose.connect("mongodb://127.0.0.1:27017/examrooms",{useNewUrlParser: true})
const db=mongoose.connect()
Here is the error
MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
Examining the mongodb.conf file shows the following
sudo cat /etc/mongodb.conf
# mongodb.conf
# Where to store the data.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongodb.log
logappend=true
bind_ip = 127.0.0.1
#port = 27017
Security is off by default. So I have the ip correct and am assuming the port is default to 27017.
Clearly am passing a string as the uri, so is this as symptom of something else? Perhaps permissions? Am stumped. Any pointers are really appreciated.