0

I've started node js and are simply building a node server. I put the same code as the picture below in index.js and executed node index.js. The following error occurred in the terminal below. Can you tell me how to solve it?

enter image description here

wook
  • 1
  • 1

2 Answers2

1

You probably already have a node application open at port 8080.

Try changing your port.

You can check if the PORT number is available by using the command:

netstat -tulnp | grep <port no>

or you can use lsof:

lsof -i :<port no>

  • Thanks for the comment! I tried your code but terminal says 'Command syntax is not correct.' – wook Oct 08 '21 at 05:15
  • Oh, are you using windows? Then try `netstat -ano | findstr :` . To kill the process, do `taskkill /PID /F` . Your should be the number at the end of the process list. For more info: https://stackoverflow.com/questions/39632667/how-do-i-kill-the-process-currently-using-a-port-on-localhost-in-windows – Daniel Kang Oct 08 '21 at 05:20
  • Also, did you try changing your port number? – Daniel Kang Oct 08 '21 at 05:21
1

You are using restricted port PORT INFO source

try using port 3000

EDIT: You CAN run on a restricted port if you have admin rights

Admin CMD

Proof