---
title: "How to Open a Port in Your Firewall"
description: "I was recently asked how to open ports within the firewall. Since it's been quite a while since I've had to do something like this, I took the time to relearn and write some documentation. In this..."
url: https://www.inmotionhosting.com/support/server/ssh/how-to-open-a-port-in-your-firewall/
date: 2013-05-17
modified: 2023-01-27
author: "Brad Markle"
categories: ["SSH and Root Access"]
type: post
lang: en
---

# How to Open a Port in Your Firewall

I was recently asked how to open ports within the firewall. Since it’s been quite a while since I’ve had to do something like this, I took the time to relearn and write some documentation.

In this tutorial, I’ll cover how to open a port on your server and test that it is open. More specifically, we will open port 9090.

Please note! This tutorial assumes you have a [VPS Server](https://www.inmotionhosting.com/vps-hosting) or a [Dedicated Server](https://www.inmotionhosting.com/dedicated-servers), that you have [root access](/support/server/ssh/root-access-faq/), and that you know how to [connect to your server via SSH](/support/server/ssh/how-to-login-ssh/).

## Step 1: Check if the Port is Open Already

The first thing we want to do is [test using telnet](/support/email/communicating-email-server-telnet/) to ensure port 9090 is not already open. Please note that you may need to [enable telnet](/support/website/enable-telnet/) in Windows first. The command below was run from cmd.exe in Windows 7:

telnet example.com 9090

And we got the following results:

Connecting To example.com...Could not open connection to the host, on port 9090: Connect failed

As you can see, the connection failed.

## Step 2: Open the Port

To open a port, first open for edit your APF configuration file – /etc/apf/conf.apf:
(The below was ran within PuTTY after connecting vis SSH)

vim /etc/apf/conf.apf

Then, find the following lines and add the port in question:

# Common ingress (inbound) TCP ports IG_TCP_CPORTS="20,21,25,53,80,110,113,143,443,465,993,995,2049,2077,2078,2082,2083,2086,2087,2089,2095,2096,3306,5222,9090,12001" # Common ingress (inbound) UDP ports IG_UDP_CPORTS="53,161,32786,111,2049,9090"

After editing the file and adding the ports, restart APF:

service apf restart

## Step 3: Test Again to See if the Port is Open

Now that APF is restarted, we can once again use telnet to test if the port is open:
(The command below was ran from cmd.exe in Windows 7)

telnet example.com 9090

Connecting To example.com... 220-vps###.inmotionhosting.com ESMTP Exim 4.80 #2 Fri, 17 May 2013 05:11:39 -0700 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.

As you can see, instead of the *Connect failed* message, we received the greeting from the application running on port 9090. Congratulations, you now know how to open a port on your server using ssh!

**Please note!** If you do not have any services running on your server listening to the port in question, you won’t get a response when you do a telnet test. In the above scenario, we [setup exim to listen on port 9090](/support/server/ssh/how-to-run-exim-on-an-additional-port/), which is why we received a response.
