Reputation: 21238
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)
Upvotes: 4
Views: 4619
Reputation: 379
the port that your localhost is listening to, is being used by some other application/service. try changing the port at the following location to a different port number like 8888 or 3000 and you should be good to go.
/Users/henrikpetersson81/node/last/test4/app.js
Upvotes: 0
Reputation: 1082
I had a similar issue, where port:3000 is solely used by node.js script. Killing the PID worked for me for port:3000.
lsof -i :3000
kill -9 <PID>
Upvotes: 0
Reputation: 1
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)
Upvotes: 0
Reputation: 21238
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.
Upvotes: 1
Reputation: 146084
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.
Upvotes: 2