I've been getting a lot of strange error message lately, and now I can't even get app.js started. What could the following mean, and does anyone know how to solve it?
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot read property 'port' of null
at Object.<anonymous> (/Users/henrikpetersson81/node/last/test4/app.js:15:64)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)
The port is propably already used. It was with me the case.
Saw a similar question recently. You could be experiencing a similar issue. Perhaps one of the libraries you are using (or your own code) is trying to access app.address().port
before the app.listen
has completed and the corresponding callback has been invoked.
I found an article explaining the same error message, and it's a problem with the port. I changed the port from 3000 to 5959 and now it works. Strange though that the port suddenly stopped working.
I had the same issue. It turns out while using nodemon( or simple for that matter) when u kill the node server it might not have been killed, so a server is still listening to 3000 port. To overcome this simple close the terminal and restart the server.(On ubuntu machine , using node and Nodemon)