I have a server which listens on port 80 for incoming requests - using HttpListener. I've found that to be able to do that, I need to open up the port (add a firewall rule which enables me to listen on port 80). I've also made a method for removing this rule again, but if someone asks me why that's a good idea, I don't really know how I should answer. I think it's a good idea to clean up after your software's done with whatever it's doing, but is there some kind of security aspect to this or something that I'm missing?

Why is it a good idea to remove the firewall rule again after application exit?


It's definitely a good idea to clean up your firewall rules every so often, for me it's primarily for security and also good housekeeping.


To keep it short, even if you did limit the rules to application names and/or exe hashes, it still provides a security risk to have a port open if you're not using it, so removing it when you're done is definitely best practice from a security standpoint, I don't think there's a security admin around who would disagree with that.

Good Housekeeping

Firewall rules can add up. If you ever have to troubleshoot, or want to see if a rule already exists, it can be a pain to have to dig through tons of rules, and if you have to unnecessarily dig through obsolete rules (depending on your firewall this may or may not be a problem) then it becomes a waste of time and can actually raise your stress level depending on if there's a crisis at hand or not. Keep it tidy, reduce the stress.

Ultimately it's up to you, since you're the one that maintains it, but that is why I prefer to delete the rules once I'm done. I don't do it after every app removal, but every so often when I'm adding a new rule or updating a rule I look and see if any can be deleted.

  • I think the OP knows how to do it they want to know why they should or should not be doing it. – user9517 supports GoFundMonica Nov 24 '14 at 9:22
  • @Iain heh, whoops, well it was 4am here, time to revise I guess. – MDMoore313 Nov 24 '14 at 11:54
  • @Iain how's that? – MDMoore313 Nov 24 '14 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.