Once in your server, open the following file in your favorite text editor:
/etc/apf/conf.apf
Use your editor’s search function to find the following line:
# Common inbound (ingress) TCP ports
IG_TCP_CPORTS="20,21,22,25,53,80,110,143,443,465,993,995"
Besides this ingress TCP entry, you should also see similar lines for UDP and ICMP ports, and outbound (egress) entries for all three packet types. For the most part, when a program needs a port opened, it needs inbound TCP opened. If you open the port following these article, and you still encounter problems, check to make sure the program does not need outbound TCP opened, or another packet type altogether.
Add the port that your program is requesting by adding the port number to the list. Make sure it is separated from other ports by commas.
After saving and closing out of your text editor, you will need to restart APF. This is as simple as running:
apf -r