Open customized Port in Windows Firewall
Windows Server contains a firewall program called "Windows Firewall with Advanced Security". This firewall automatically configured so that access to programs will be allowed. However, not all applications will be automatically configured. In this case, you will need to configure the port manually.
Step 1
Configure default firewall settings
Determine if incoming/outgoing connections will be blocked or allowed by default unless a rule is explicitly made. To do this, open the "Windows Firewall with Advanced Security" panel. Go to the "Windows Firewall with Advanced Security on Local Computer" section, and right-click "Properties" in the sidebar.
Make sure the firewall is enabled by confirming that "Firewall state" is set to "On (recommended)" and not to "Off".
You want inbound connections to be blocked by default so that only firewall rules manually added will be accepted. Whether you want outbound connections depends on if you have users on your server. For example, if you only want your users to use websites, you can set outgoing connections to "Block" then specify ports or applications that can be used for outgoing connections.
Step 2
Opening an inbound port
In order to open an inbound port, go to "Inbound Rules" under the "Windows Firewall with Advanced Security on Local Computer", and click "New Rule..." in the sidebar.
Step 3
Choose "Port" as the kind of rule you want to create. This will allow you to create rules for inbound connections to both TCP and UDP ports. Click "Next". If you need to open both TCP and UDP ports, you will need to create a separate rule because a single rule can only apply to TCP or UDP, not both. Depending on the port you want to open, choose "TCP" or "UDP". If you are not sure which one to choose, refer to the manual of the program you are configuring.
Step 4
Next, choose "Specific local ports" so that you can manually set which ports need to be opened with the rule. For example: "80". You can also open multiple ports with one rule, with a comma-separated list: "80, 443". We can also set a range of ports to be opened: "72-90". This will open all ports between 72 and 90. We can also combine this: "80, 443, 72-90". This will open the ports 80, 443, and all ports between 72 and 90. Click "Next".
If you have set the properties of your firewall to automatically allow all incoming connections, you can choose "Block the connection" to block those specific ports. If you have set all incoming connections to "Block (default)", though (which I recommend), you can choose "Allow the connection" to allow the incoming connection. Click "Next".
You can determine when the rule applies. When the computer is joined to a domain, you can check "Domain" to allow the connection. Checking "Private" will allow people connected to a private network to connect to that port.
Same for "Public", the only difference being that people on a public network will be able to connect to that port.
After checking everything you want, click "Next".
Step 5
Give the rule a name now. It is always recommended to give it a clear name so that you know what it does. You can also give it a description to elaborate further.
When you're done, click "Finish". External programs can now connect to the port that was opened.