I am trying to follow this tutorial: https://medium.com/@bryantheastronaut/react-getting-started-the-mern-stack-tutorial-feat-es6-de1a2886be50
I'm stuck because I can't find a way to connect my mLab database to node. I have figured out that the <> around the user name and password need to be removed from the string, but I still can't get it to connect.
mongoose.connect('mongodb://Testerxxx:Testxxx@ds157057.mlab.com:57057/testxxxx');
The log shows the error as:
(node:91198) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
09:37:34 api.1 | events.js:183
09:37:34 api.1 | throw er; // Unhandled 'error' event
09:37:34 api.1 | ^
09:37:34 api.1 | Error: listen EADDRINUSE :::3001
09:37:34 api.1 | at Object._errnoException (util.js:1022:11)
09:37:34 api.1 | at _exceptionWithHostPort (util.js:1044:20)
09:37:34 api.1 | at Server.setupListenHandle [as _listen2] (net.js:1351:14)
09:37:34 api.1 | at listenInCluster (net.js:1392:12)
09:37:34 api.1 | at Server.listen (net.js:1476:7)
When I follow the link to the readme for this error: http://mongoosejs.com/docs/connections.html#use-mongo-client, I can't actually see any instructions that differ from those in the tutorial.
Can anyone see what's wrong with this from. I've used the exact string from the Mongo DB connect page, inserting the mongoose.connect bit at the front.
Can anyone point to more detailed instructions for connecting to mLab?
Another hypothesis:
When I run npm run start-dev, the terminal shows a message that says:
Local: http://localhost:3000/ 12:58:52 web.1 | On Your Network: http://10.0.0.2:3000/ 12:58:52 web.1 |
However, the page I'm trying to check is port 3001 (per the tutorial). My server.js file also asks for the 3001 port to be used:
var port = process.env.API_PORT || 3001;
Maybe the reason why I can't get a response for the mLab connection is something to do with the difference in ports. If that's the case, I don't understand because, to this point, I have followed the tutorial in the setup.