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?
Asked
Active
Viewed 1,614 times
0
-
1please paste the code and error output next time – Andrew Oct 08 '21 at 04:15
-
1It says 'permission denied'. You should start the terminal as adminstrator (in windows) or use -sudo in macand linux – ABDULLOKH MUKHAMMADJONOV Oct 08 '21 at 04:17
-
1Let me know if this solved your problem – ABDULLOKH MUKHAMMADJONOV Oct 08 '21 at 04:17
-
Thanks for the comment! I started terminal like what you said but it called same error – wook Oct 08 '21 at 05:09
2 Answers
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>

Daniel Kang
- 34
- 5
-
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 – Daniel Kang Oct 08 '21 at 05:20/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 -
1
You are using restricted port
source
try using port 3000
EDIT: You CAN run on a restricted port if you have admin rights