How To Open Ports On Ubuntu

Opening specific ports on your Ubuntu server is essential for allowing communication through services like HTTP, HTTPS, SSH, and FTP. Properly configuring open ports ensures network services respond correctly while maintaining security. However, exposing ports unnecessarily can pose security risks.

Last updated 30 Nov 2026Also in: Dedicated Servers, Security

Opening specific ports on your Ubuntu server is essential for allowing communication through services like HTTP, HTTPS, SSH, and FTP.

Properly configuring open ports ensures network services respond correctly while maintaining security. However, exposing ports unnecessarily can pose security risks. To minimize vulnerabilities, only open the ports you need and implement robust security practices, such as strong passwords and regular system monitoring.

Ubuntu uses UFW (Uncomplicated Firewall), a user-friendly command-line utility that simplifies firewall management. UFW allows you to define rules for filtering incoming and outgoing traffic, making it an effective tool for securing your server while maintaining accessibility for essential services.

How to Open Ports Using UFW

Follow these steps to open ports on Ubuntu using UFW:

Check UFW Status

  • Ensure UFW is active and check its current status:
sudo ufw status

Allow Specific Traffic

  • HTTP (Port 80)
sudo ufw allow http
  • HTTPS (Port 443)
sudo ufw allow https

**Specify Port and Protocol:**For example, to allow incoming TCP traffic on port 8080:

sudo ufw allow 8080/tcp 
  • Allow incoming UDP traffic on port 53:
sudo ufw allow 53/udp

Enable UFW

  • Apply the changes by enabling UFW
sudo ufw enable

Verify Rules

  • Confirm the port is open by checking UFWโ€™s status again.
sudo ufw status

How to Close Ports Using UFW

To deny access to a previously opened port, use the deny command. For example:

  • Close HTTP traffic:
sudo ufw deny http
  • Close HTTPS traffic:
sudo ufw deny https

Replace http, https, or port numbers with the appropriate service or port you wish to close.


Best Practices for Opening Ports

  • Open Only Necessary Ports: Minimize exposure by enabling only essential services.
  • Secure Your System: Use strong passwords, update software regularly, and monitor for suspicious activity.
  • Test Changes: Verify port configurations after each adjustment to ensure functionality and security.

By carefully managing open ports and adhering to security best practices, you can maintain a secure and efficient Ubuntu server environment.

That will be all!

cloud servers in kenyaservers