Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Short answer: connect to the VPS, allow your SSH service first, add an inbound rule for the application port, enable UFW, and verify the resulting policy. For example, an application using TCP port 8080 can be opened with sudo ufw allow 8080/tcp. Do not run sudo ufw enable on a remote VPS until SSH is allowed, or the firewall can block your management session.

What UFW does—and what it does not do

UFW (Uncomplicated Firewall) is Ubuntu’s default firewall configuration tool. A new Ubuntu installation normally has UFW disabled, so adding a rule alone does not enforce a firewall policy until you enable it. UFW’s simple command syntax is designed for straightforward allow and deny rules; it is not a complete replacement for every advanced firewall, routing, or network-policy requirement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An allow rule changes the firewall on the VPS itself. It does not start a web server, make an application bind to a socket, or change a hosting company’s network firewall. If a client still cannot connect after UFW shows an allow rule, check the service and any provider-level firewall, security group, or network ACL separately.

Before you change anything on a remote VPS

Keep an active SSH session

Leave your current SSH connection open while changing UFW. If a rule is wrong, that session may be your easiest way to correct it. Test a second connection in another terminal after the rules are in place before closing the first one.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.

Identify the real SSH port

If SSH uses the standard TCP port 22, you can allow it with sudo ufw allow ssh or sudo ufw allow 22/tcp. If the SSH daemon listens on a custom port, replace 22 with that port. Allowing port 22 when SSH actually listens elsewhere does not protect your management connection.

Know the application protocol

TCP and UDP are separate protocols. A rule that names TCP does not open UDP on the same number. UFW accepts a port with an optional protocol; omitting the protocol allows both TCP and UDP, which is broader than many services need. Use an explicit protocol whenever the application documentation identifies one.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Open a port safely: the complete procedure

1. Allow SSH before enabling UFW

For standard SSH, run one of these commands:

sudo ufw allow ssh
sudo ufw allow 22/tcp

Use only one equivalent SSH rule unless you deliberately want both entries. For a custom SSH port, substitute the actual port number:

sudo ufw allow 2222/tcp

The number 2222 is an example; use the port configured by your SSH service.

2. Add the application rule

For an inbound TCP service on port 8080:

sudo ufw allow 8080/tcp

For a service that genuinely needs both protocols, omit the protocol:

sudo ufw allow 8080

Use the actual listening port rather than the port exposed by a local development configuration or a container’s internal network unless they are the same endpoint seen by the VPS network.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Preview a rule when you want a non-destructive check

UFW can print the rules it would create without applying the change:

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
sudo ufw --dry-run allow http

The output lets you inspect the resulting rule before committing it. You can replace the service name with another supported service name or use the port-and-protocol form for a custom service.

4. Enable the firewall

sudo ufw enable

Enabling UFW activates the policy and its rules. On a remote machine, perform this only after the correct SSH allow rule is present.

5. Inspect the active policy

sudo ufw status verbose
sudo ufw status numbered

status verbose provides the policy’s expanded view. status numbered adds rule numbers, which are useful when you need to delete or reorder a particular entry. Confirm that the SSH rule and the intended application rule appear with the expected protocol.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common port-opening examples

Purpose Command Protocol and exposure
Standard SSH sudo ufw allow 22/tcp TCP; available from any source unless further restricted
SSH service by profile name sudo ufw allow ssh Uses UFW’s SSH application profile
HTTP service sudo ufw allow http Uses an available application profile; inspect profiles first if unsure
Custom web or API service sudo ufw allow 8080/tcp TCP only on port 8080
Both TCP and UDP on one number sudo ufw allow 8080 Both protocols; use only when the service requires both

The profile-based examples depend on a matching UFW application profile being installed. A raw port rule is more explicit for a custom service.

Restrict an administration port to trusted addresses

Opening SSH to every source is convenient but exposes the management service to the entire internet. If you have a stable office, VPN, or bastion address, restrict the rule to that source:

sudo ufw allow proto tcp from 203.0.113.10 to any port 22

The address 203.0.113.10 is an example source address. Replace it with the public address from which you administer the VPS. A network can be expressed in CIDR notation:

sudo ufw allow proto tcp from 203.0.113.0/24 to any port 22

A CIDR rule covers every address in that range, so choose the narrowest range that contains your legitimate administrators. Before tightening an existing rule, verify that your current connection originates from an address included by the new rule and keep the existing session open while testing.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Use an application profile instead of a raw port

Some software installs a named UFW application profile. Profiles are stored under /etc/ufw/applications.d. Discover the profiles available on the VPS:

sudo ufw app list

Inspect a profile’s ports and description before allowing it:

sudo ufw app info NAME

Replace NAME with the exact profile name shown by app list, then allow that profile:

sudo ufw allow 'NAME'

Profile names can contain spaces, which is why quoting the name is prudent. A profile is useful when the package maintainer defines the service’s ports for you; a raw rule such as sudo ufw allow 8080/tcp is clearer for a one-off or custom application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand protocol, source, direction, and interface choices

Decision Narrower choice Broader choice Why it matters
Protocol Specify /tcp or /udp Omit the protocol Omitting it permits both TCP and UDP on the port.
Source One IP or a CIDR range Any source A source restriction reduces who can reach administration or private services.
Management method Named application profile Raw port rule Profiles describe packaged services; raw rules suit custom ports.
Network layer Host UFW rule Provider firewall or ACL change Both layers can affect reachability; changing UFW does not alter provider controls.
Address family Check the displayed IPv4 and IPv6 entries Assume one family covers both Rules can be represented separately for IPv4 and IPv6, so inspect the actual status output.

Most commands in this guide create inbound access to the VPS. If your design depends on a particular network interface, routed traffic, forwarding, or more complex policy, the simple UFW command interface may not express the requirement completely.

Inspect, remove, and reorder rules

List numbered rules before editing

sudo ufw status numbered

Numbered output is the safest starting point when several similar rules exist. Record the exact rule text as well as its number; numbers can change after an earlier rule is deleted.

Delete by repeating the original definition

To remove the example TCP rule, repeat its original definition after delete:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
sudo ufw delete allow 8080/tcp

Deleting by the original rule text is useful when you know exactly what was added. For a rule displayed in numbered output, UFW also supports deletion by number. The manual warns that deleting a generic rule by number can affect only the specified IPv4 or IPv6 entry; deleting by the original rule text removes both where applicable. After any deletion, run sudo ufw status numbered again and verify the remaining policy.

Reordering considerations

When rules overlap, the order shown by UFW can matter. Use numbered status output to understand the current order before changing it, and make one change at a time. If the policy has grown beyond simple service allows, document the intended source, protocol, and destination for every rule before editing.

Verify that the service—not just UFW—is ready

An allow rule only tells the host firewall to permit matching traffic. The application must also be running and listening on the expected port and address. Check the application’s own configuration and service status, then inspect the VPS’s listening sockets with an appropriate socket-inspection tool. For example, on a system with the standard ss utility, you can inspect listening TCP sockets with:

sudo ss -lntp

Look for the expected port and confirm that the process is bound to an address reachable by the client. A service bound only to a loopback address such as 127.0.0.1 is local to the VPS even when UFW allows the port. Conversely, a service listening on the wrong port will not receive connections to the port you opened.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Test from a separate machine or network, not only from the VPS itself. A local test can succeed while an external client is blocked by a provider firewall, security group, or network ACL. Those controls are outside UFW and must be reviewed in the VPS provider’s management panel or network configuration.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot an “open” port that is unreachable

UFW is still disabled

Run sudo ufw status verbose. If it reports that UFW is inactive, the rules are not enforcing a host firewall policy yet. Confirm the SSH rule first, then enable UFW with sudo ufw enable.

The wrong protocol was opened

Check whether the client uses TCP or UDP and compare that with sudo ufw status numbered. A TCP rule does not allow UDP traffic, and vice versa. If the service requires both, use a rule without a protocol or create explicit rules for each protocol according to the service’s requirements.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

The service is not listening

Use the application’s service status and a socket inspection tool to verify that a process is bound to the expected port. Restart or reconfigure the application only after confirming its documented listening address and port. UFW cannot create a listener for a stopped service.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The service is bound only to localhost

If socket inspection shows a loopback-only address, change the application’s bind address according to its documentation, then retest. Opening UFW does not make a loopback-bound process externally reachable.

A provider-level firewall is blocking traffic

When UFW is active, the rule is correct, and the service is listening, inspect the VPS provider’s firewall, security group, and network ACL. These controls can deny traffic before it reaches the operating system, so changing UFW alone cannot resolve that block.

SSH access was lost after enabling UFW

Use an existing SSH session, an out-of-band console, or the provider’s recovery console if available. Add an allow rule for the actual SSH port, then inspect status. If SSH uses a custom port, adding a rule for port 22 will not restore access to that service.

An old or duplicate rule is confusing the policy

Run sudo ufw status numbered, identify duplicate or obsolete entries, and remove them using the original definition or the displayed number. Recheck both the protocol and the source restriction after every edit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Practical patterns for common deployments

Public web service on ports 80 and 443

Allow the web service’s TCP ports using installed profiles when available, or explicit TCP rules when the service is custom. Confirm that the web server is listening on the public interface and that the provider’s network firewall permits the same ports. Do not assume that an HTTP profile automatically opens every port used by a reverse proxy or application server.

Private API on port 8080

If only another server should call the API, use a source-restricted TCP rule instead of sudo ufw allow 8080/tcp from anywhere. The source should be the caller’s stable public IP or an appropriate CIDR range. Verify both ends: the API listener must be reachable on its intended address, and the caller must be permitted by any provider-level controls.

Administrative service on a custom SSH port

Determine the configured SSH port, allow that TCP port before enabling UFW, and test a second connection using the same port. Once confirmed, remove any unnecessary broad SSH rule. A nonstandard port is not a substitute for source restrictions, strong authentication, or other SSH hardening; it only changes which port the daemon uses.

Operational checklist

  • Keep the current remote session open.
  • Confirm the actual SSH port and allow it before enabling UFW.
  • Identify whether the application needs TCP, UDP, or both.
  • Use the narrowest source IP or CIDR range practical for administrative services.
  • Preview a sensitive change with sudo ufw --dry-run when appropriate.
  • Add the application rule or inspect and allow its UFW profile.
  • Enable UFW only after management access is covered.
  • Check both sudo ufw status verbose and sudo ufw status numbered.
  • Verify that the application is running and listening on the expected address and port.
  • Test from an external client and inspect provider firewalls, security groups, and ACLs if it still fails.
  • Record the original rule text before deleting or changing entries.

Where UFW stops being the right abstraction

UFW is intentionally convenient for adding and removing simple rules. Ubuntu describes its scope this way: “ufw is not intended to provide complete firewall functionality via its command interface, but instead provides an easy way to add or remove simple rules.” If you need intricate forwarding, routed-network policy, interface-specific designs, stateful exceptions, or a large rule set, plan the policy at the appropriate firewall layer rather than forcing it into a single simple allow command. For ordinary VPS service exposure, however, the disciplined sequence—protect SSH, allow the required protocol and port, enable, inspect, and validate the listener and provider network—prevents the most common lockouts and false diagnoses.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.