how to close open sockets in linux code example
Example 1: how to close sockets ubuntu
sudo netstat -ap | grep :<port_number>
#The second line will contain the process id. e.g: 7838/python3 (7838 is the pid)
kill <pid>
Example 2: debian kill open port
fuser -k 3000/tcp //will kill that process.
Example 3: how to close port in linux
sudo ufw allow PORT