How to remove access to a port using firewall on Centos7?

Solution 1:

Solution: Do not forget the --runtime-to-permanent

$ firewall-cmd --zone=public --remove-port=10050/tcp
$ firewall-cmd --runtime-to-permanent 
$ firewall-cmd --reload 

Solution 2:

# firewall-cmd --zone=public --remove-port=12345/tcp --permanent
# firewall-cmd --reload

Replace 12345 with the port you want to remove.