lsof command can be used to check which process is occupying port 8080. lsof command stands for List Of Open File.
It provides a -i option that can be used to check the files that might have been opened by some network connection in the system. It lists all UDP and TCP connections.
Type the below command
lsof -i tcp:8080
It will tell you which process is occupying port 8080. Below is the output on my system.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
main 35631 <user> 3u IPv6 0x5a460c6a5bab1b15 0t0 TCP *:http-alt (LISTEN)
The output also has the PID of the process which I can then use to kill the process. Below is the command to kill the process
kill -9 <pid_of_process>