Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk8 min

Which Ports Should Be Open on an Ubuntu LAMP Server?

A secure Ubuntu LAMP server usually exposes Apache on 80 and 443, restricts SSH to trusted networks, and keeps MySQL 3306 private. This guide explains the decisions, UFW configuration and verification commands.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a normal internet-facing Ubuntu LAMP server, make Apache reachable on TCP 80 and 443, restrict SSH to trusted administrative networks on its actual configured port, and keep MySQL on localhost or a private subnet. Every other listener should have a documented purpose.

Start with the minimum reachable surface

A LAMP server combines Linux, Apache, MySQL and PHP, but those components do not all need to accept connections from the internet. A process can be running without being reachable externally, and a firewall rule can exist for a port where no process is listening. Treat those as two separate checks: decide who should be able to connect, then verify that the intended service is actually bound to the right address.

As an Amazon Associate I earn from qualifying purchases.

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.

Canonical’s Ubuntu security guidance describes an unnecessarily open port as one exposed to an untrusted network without a need, or one belonging to an unused service. Its practical advice is to limit traffic with a firewall and close listeners that the design does not require. A new Ubuntu installation should have no listening network services by default, apart from deliberate exceptions such as Apache HTTP Server and OpenSSH.

Port decisions for a typical LAMP host

Service Typical port When it is public Recommended scope
HTTP / Apache TCP 80 When the site serves HTTP or redirects visitors to HTTPS Public, if the web design needs it; otherwise close it
HTTPS / Apache TLS TCP 443 When the website serves encrypted HTTPS traffic Public for a secure internet-facing website
SSH / OpenSSH TCP 22 by default, or the port configured in sshd_config For administration only Trusted IP addresses, a VPN, bastion host or management subnet
MySQL TCP 3306 Normally never on the public internet Loopback for a single-host application, or only the required private application hosts

These are conventions, not proof that a service is installed. Apache may be configured on another port, OpenSSH may have been moved from 22, and MySQL may be disabled from TCP networking altogether. The configured listener and the network policy must agree.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

TCP 80: HTTP for delivery or redirecting

Open TCP 80 publicly when Apache is meant to answer ordinary HTTP requests. Many sites retain it solely to redirect an http:// request to the HTTPS virtual host. That redirect still requires port 80 to be reachable; closing it means clients cannot receive the redirect and must already know the HTTPS URL.

If the server is intended to serve only an internal application, a private load balancer, or HTTPS on a different edge device, there may be no reason to expose 80 on the Ubuntu host. In that case, omit the public rule and ensure the upstream design does not depend on direct HTTP access.

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

TCP 443: HTTPS for the public website

TCP 443 is the normal public entry point for Apache TLS. Use HTTPS for credentials, sessions, forms and other data in transit. The certificate and TLS configuration live in Apache; the firewall only controls whether connections can reach that service.

A common production arrangement exposes both 80 and 443: port 80 performs a controlled redirect, while 443 serves the site. If an upstream reverse proxy terminates TLS, the Ubuntu host might receive traffic from that proxy on a private interface rather than directly from the internet. In that architecture, permit only the proxy’s network on the backend listener instead of making every backend port public.

SSH: administration, not application traffic

OpenSSH is for maintenance: shell access, file transfer and operational tooling. It is not required for visitors to load PHP pages. Port 22 is the default example used in Ubuntu documentation, but the correct rule is the port on which your sshd process is actually configured.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Restrict the source network whenever possible. A VPN, bastion host or management subnet is preferable to allowing the entire internet. If a fixed administrative address or range is available, express that source restriction in UFW rather than creating a worldwide allow rule.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo ufw allow proto tcp from <trusted-network> to any port 22

Replace both the source and destination port when your deployment uses a different SSH port. Before changing SSH policy, keep an existing session open or arrange console access so a typo cannot lock out administrators. Authentication hardening, keys and intrusion monitoring complement a narrow firewall rule; they do not make an unnecessary public listener necessary.

MySQL 3306: keep the database private

In a single-host LAMP deployment, Apache/PHP and MySQL run on the same machine. The application can connect through a local socket or loopback address, so the database does not need a public TCP 3306 rule. Bind MySQL to localhost when no other host must connect, and allow the firewall to deny unsolicited external traffic.

A multi-host design changes the scope, not the security principle. If the PHP application is on an application server and MySQL is on a separate database host, permit 3306 only from the application host or private subnet that needs it. Do not use a broad public allow rule as a shortcut. Where database traffic crosses a network, evaluate encrypted MySQL connections as well as firewall restrictions.

Check MySQL’s bind-address and any host-based account grants together. A firewall rule cannot safely compensate for a database process listening on every interface with permissive credentials, and a loopback bind cannot serve a remote application even if UFW allows the port.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Configure UFW without locking yourself out

Ubuntu identifies Uncomplicated Firewall (UFW) as its default firewall configuration tool. Apply rules that match the architecture, then inspect the resulting policy.

  1. Confirm the administrative path. Determine the SSH port in use and identify the trusted address, VPN or management subnet that should reach it.
  2. Allow restricted SSH first. Use the source-limited form shown above, substituting the actual port. If the service is intentionally reachable from a wider management network, document that decision.
  3. Allow web traffic required by the site. Permit TCP 80 when HTTP service or redirects are needed, and TCP 443 when Apache serves HTTPS. Ubuntu also supports application profiles; inspect available profiles with sudo ufw app list and details with sudo ufw app info <profile>.
  4. Keep MySQL closed publicly. Do not add a 3306 allow rule for a single-host LAMP stack. For a private multi-host design, create a source-restricted rule that names only the application network.
  5. Review before enabling or changing policy. Display the active rules and defaults with sudo ufw status verbose. To preview an HTTP rule without changing the firewall, use sudo ufw --dry-run allow http.

Ubuntu’s firewall guide gives sudo ufw allow 22 as the basic SSH example. That command allows the port from any source, so a production server should use the narrower source form whenever the administrative network is known. Use the actual SSH port rather than assuming 22.

Verify what is really listening

Firewall intent is only half the check. List listening sockets and their owning processes with:

sudo ss -utlnp

The output shows protocol, local address, port and process information. Compare every listener with the service design:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • 0.0.0.0:80 or 0.0.0.0:443 indicates an IPv4 listener on all IPv4 interfaces.
  • [::]:80 or [::]:443 indicates an IPv6 listener on all IPv6 interfaces; IPv6 policy must be checked as well.
  • 127.0.0.1:3306 or ::1:3306 is loopback-only and is not publicly reachable through that address.
  • A private address such as the server’s internal interface limits reachability to networks that can route to it, but still requires a matching firewall rule.

Use the process name in the ss output to find the configuration responsible for an unexpected listener. Stop an unused service or rebind a required service to loopback or a private interface, then verify again. Do not infer exposure from package installation alone: a package can be installed with no active listener, and a custom application can listen on an unexpected port.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check both firewall paths and bind addresses

IPv4 and IPv6 are separate paths. A rule that appears correct for IPv4 does not prove that an IPv6 listener is protected. Review UFW’s verbose status and the local addresses reported by ss; test from the relevant network family when your provider supplies both.

Likewise, “closed” can mean different things. A service may be stopped, blocked by UFW, bound only to loopback, or reachable only through a private route. Record which condition is intentional so an incident responder can distinguish a design choice from a failed service.

Practical deployment patterns

One public Ubuntu host

Expose 80 and 443 to the internet if Apache handles HTTP and HTTPS. Limit SSH to the administration network. Keep MySQL on localhost. This is the usual small-site LAMP arrangement and has the fewest network dependencies.

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

HTTPS-only site behind a redirect elsewhere

If another edge service owns the HTTP redirect and TLS termination, the Ubuntu host may need neither public 80 nor public 443. Allow only the edge service’s private connection to the backend port, and verify that Apache is not accidentally listening on a public interface.

Separate application and database hosts

The web or application host needs its user-facing ports, while the database host needs 3306 only from the application host or private subnet. SSH remains an administrative path on each machine and should be restricted independently.

Private staging server

A staging site may expose Apache only to a VPN or internal network rather than the internet. The same least-exposure rules apply: allow the source networks that need access and leave database and unused service ports closed.

Common mistakes and recovery steps

Opening 3306 “temporarily”

A temporary public database rule often remains after troubleshooting. Remove it when remote access is no longer required, restore a private bind address, and verify with ss and UFW status. If remote administration is occasional, use a VPN or controlled tunnel instead of a standing internet-wide rule.

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.

Allowing SSH before confirming the port

If SSH was moved from 22, an allow rule for 22 does not protect or permit the real service. Read the active sshd configuration, add the correct restricted rule, test a second session, and only then remove an obsolete rule.

Assuming a firewall rule creates a service

sudo ufw allow 443 does not make Apache serve HTTPS. Confirm that Apache has a TLS virtual host, a certificate and a listening socket. Conversely, seeing a listener does not mean the port is reachable externally; its bind address and firewall policy decide that.

Forgetting the HTTP redirect dependency

Closing 80 on a site that expects automatic HTTP-to-HTTPS redirects causes those requests to fail rather than redirect. Either keep 80 for the redirect or communicate an HTTPS-only URL and verify client behavior.

Relying on a nonstandard port as security

Changing SSH from 22 can reduce noise but does not replace source restrictions, strong authentication and updates. Treat the configured port as an implementation detail and apply the same administrative-only policy.

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

A repeatable audit checklist

  • List listeners with sudo ss -utlnp.
  • Identify the process, local address and protocol for every listener.
  • Confirm public 80 and 443 are present only when the web architecture requires them.
  • Find the actual SSH port and restrict its source network.
  • Verify MySQL is loopback-bound or limited to the required private hosts.
  • Review IPv4 and IPv6 listeners separately.
  • Inspect UFW with sudo ufw status verbose and review application profiles when used.
  • Remove rules for retired services and investigate any listener without a documented owner.

The governing rule is simple: expose the smallest set of ports that supports the architecture, to the smallest set of networks that needs them. Canonical’s guidance captures the reason: “Therefore, it’s good practice to limit the network traffic that can reach open ports (for example, by using a firewall) and to close any unnecessarily open ports.”

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.