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.
Related
I am more than clueless at the moment. I am trying to start a keystonejs-6 app in production mode and the the app throws this error:
Starting Keystone
node:events:505
throw er; // Unhandled 'error' event
^
Error: listen EPROTONOSUPPORT: protocol not supported :::3000
at Server.setupListenHandle [as _listen2] (node:net:1355:21)
at listenInCluster (node:net:1420:12)
at doListen (node:net:1559:7)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1399:8)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'EPROTONOSUPPORT',
errno: -43,
syscall: 'listen',
address: '::',
port: 3000
}
I have no way to trace back, at which point of the keystonejs application code the error originated. As it seems, keystonejs provides practically no logging on the application code itself.
Is there a way to find out, what kind of protocol is meant by this error message?
I was trying to connect the MongoDB atlas using mongoose but this is the error I'm getting.
[nodemon] starting `node app.js`
node:events:505
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (node:net:1372:16)
at listenInCluster (node:net:1420:12)
at Server.listen (node:net:1508:7)
at Function.listen (E:\S and P Global Notes_lect\Nodetest\node_modules\express\lib\application.js:635:24)
at E:\S and P Global Notes_lect\Nodetest\app.js:11:97
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1399:8)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'EADDRINUSE',
errno: -4091,
syscall: 'listen',
address: '::',
port: 3000
}
[nodemon] app crashed - waiting for file changes before starting...
First I thought the error was in the password encoding but I solved it then I got this one
You are most likely already running the server in the same port (3000).
Check your processes and terminate the other instance of the node app that is listening on 3000
Check your network to see if port 3000 is already in use by another application
or
Change the port of your node app to listen to another unused port and the error should go away.
Error:
events.js:167
node_app_1 | throw er; // Unhandled 'error' event<br>
node_app_1 | ^
node_app_1 | Error: listen EADDRNOTAVAIL 50.177.55.2:3000<br>
node_app_1 | at Server.setupListenHandle [as _listen2] (net.js:1269:19)<br>
node_app_1 | at listenInCluster (net.js:1334:12)<br>
node_app_1 | at GetAddrInfoReqWrap.doListen [as callback] (net.js:1460:7)<br>
node_app_1 | at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:62:10)<br>
node_app_1 | Emitted 'error' event at:<br>
node_app_1 | at emitErrorNT (net.js:1313:8)<br>
node_app_1 | at process._tickCallback (internal/process/next_tick.js:63:19)<br>
Update:
Change your socker-io server's IP to 127.0.0.1
Your app is trying to listen on port 3000 and I believe it is already being used.
If you have some other service running on this port, you will either have to change the port of your socket-io server or follow the following process to kill the process that is already listening on port 3000.
Type the following in your terminal,
lsof -i:3000
It will show you the process that is listening to that port. Then you can kill that process using its process ID (PID)
kill -9 <PID>
Is there any way in node.js wherein I can start a server on a condition.
Suppose I want to load some parameters from DB into memory and if the load is successful, then only start the server else don't start.
I am a bit of a new to node.js and this seems quite a beginners question. Is it possible?
In fact, I created a conditional server start-up but I am getting the below error every time.
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3007
at Server.setupListenHandle [as _listen2] (net.js:1360:14)
at listenInCluster (net.js:1401:12)
at Server.listen (net.js:1485:7)
And I did a lookup for my application and it was not running at all. After that, I tried changing my port multiple times but no luck. The error seems persistent.
I've got a Socket.io server that is not working (it shows the following error on Firebug and of course it doesn't any of its functions):
GET http://www.example.com:1618/socket.io/1/?t=1401400488401 400 Bad Request 35ms
Also, when I try to run the server, it outputs that:
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1042:14)
at listen (net.js:1064:10)
at net.js:1146:9
at asyncCallback (dns.js:68:16)
at Object.onanswer [as oncomplete] (dns.js:121:9)
I am running it on Ubuntu 14.04
EADDRINUSE means that there is another process that is listening to the port you're using for socket.io. Try changing the port number for socket.io when listen() is called.
On ubuntu, you might need to run it with sudo:
sudo nodejs your_server.js