DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
VGSources
Blog

How to Run a Website on a Non-Standard HTTP Port on Ubuntu

A practical Ubuntu guide to serving a website on port 8080 or another custom HTTP port with Apache2 or nginx, including UFW, cloud and router access, testing, HTTPS limits, and troubleshooting.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To serve an Ubuntu website on port 8080, make the web server listen on TCP 8080, make the site’s virtual-host or server-block configuration match that port, allow 8080/tcp through every firewall or router in the path, and have visitors use http://example.com:8080/. A custom port changes where HTTP is reachable; it does not provide encryption.

What changes when you move HTTP away from port 80?

HTTP clients normally try TCP port 80 when a URL has no explicit port. If your service listens on 8080 instead, DNS still maps a hostname to an IP address, but the browser will not discover 8080 automatically. The port must be written in every URL, such as http://example.com:8080/.

As an Amazon Associate I earn from qualifying purchases.

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

Four separate pieces must agree:

  • The web server process must bind to the chosen TCP port.
  • The site configuration must select that port for the intended virtual host or server block.
  • The Ubuntu host firewall must permit incoming TCP traffic on it.
  • A cloud security group, router NAT rule, or other upstream firewall must forward and permit the same port when the server is not directly exposed to the internet.

An “open port” means a service is bound to a network port and actively listening for incoming traffic or packets. Opening a port on an untrusted network increases risk if the listening software is vulnerable or incorrectly configured, so expose only the service you intend to run and keep it patched.

Choose and check a port before editing configuration

Use an unprivileged, unused TCP port. Port 8080 is a common example, but it is not reserved for websites and may already be occupied by another application.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
  1. Pick the port you want, for example 8080.
  2. On the Ubuntu server, inspect listening sockets:
sudo ss -ltnp

Look for an existing listener on the selected port. The output identifies the local address, TCP port, and (when permitted) the owning process. Choose another port if a different service already owns it. Checking first prevents a failed reload or an accidental conflict.

Apache2: change the listening port

1. Set the global listener

Apache2’s primary port setting is /etc/apache2/ports.conf. The Listen directive specifies the port and can optionally specify an IP address. The default is commonly Listen 80; add or change it to the selected value:

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.
sudoedit /etc/apache2/ports.conf

For a site intended to answer on every local IPv4 address, use:

Listen 8080

If the file already contains Listen 80 and you want to stop serving ordinary HTTP on port 80, replace that line rather than leaving both listeners. Keeping both is valid only when you deliberately want Apache2 to serve on both ports.

An address-qualified listener can restrict binding to one interface, for example Listen 192.0.2.10:8080. Use that only when you understand the server’s interface layout; binding to the wrong address makes remote requests fail even though the configuration appears correct.

2. Match the virtual host

Apache2 chooses a virtual host using its address-and-port binding and, when supplied, the host name. Edit the enabled site file in /etc/apache2/sites-available/ (or the included configuration that defines the site) and make its opening tag use the same port:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<VirtualHost *:8080>
    ServerName example.com
    DocumentRoot /var/www/example
    # other directives for this site
</VirtualHost>

The port in <VirtualHost *:8080> must correspond to the Listen 8080 directive. If the virtual host remains on *:80, Apache2 may listen on 8080 without assigning your site to requests arriving there, producing a default page or a 404.

When several sites share the port, keep each site’s ServerName and aliases accurate. A request made by IP address, an unknown hostname, or a hostname that does not match an enabled virtual host can select a different site.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

3. Validate and apply the change

Validate the configuration before reloading so a syntax error does not interrupt the running service:

sudo apache2ctl configtest

Proceed only when the result reports a successful syntax check. Then reload Apache2 to apply the new listener without unnecessarily stopping existing workers:

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.
sudo systemctl reload apache2

If the reload fails, inspect the service status and journal, correct the reported file or directive, run the configuration test again, and reload. A restart is a more disruptive alternative and is not required for an ordinary listener change when reload succeeds.

nginx: change the server block listener

1. Edit the site’s listen directive

nginx assigns a site through a server block. Open the relevant file under /etc/nginx/sites-available/ or another included configuration path and change the listener:

server {
    listen 8080;
    server_name example.com;
    root /var/www/example;
    # other directives for this site
}

Every site that should answer on the custom port needs an appropriate, distinct listen declaration when multiple sites are configured. Keep the server_name value aligned with the hostname visitors will request; nginx uses the combination of listener and host name to select a server block.

2. Include IPv6 when the site uses it

If the existing site has an IPv6 listener, update that declaration as well. A typical pair is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
listen 8080;
listen [::]:8080;

Leaving an old listen [::]:80 while changing only IPv4 can create confusing, address-dependent behavior. Conversely, do not add an IPv6 listener if the host has no configured IPv6 address or your network intentionally disables IPv6.

3. Test and reload nginx

Check the complete nginx configuration, including included files:

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
sudo nginx -t

After a successful test, apply the change:

sudo systemctl reload nginx

For a configuration error, use the file and line reported by the test output, fix it, run nginx -t again, and reload only after the test passes.

Open the port in Ubuntu’s UFW firewall

Ubuntu commonly manages host firewall policy through UFW. Allow the exact TCP port, not every protocol on that number:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo ufw allow 8080/tcp

To preview the rule before changing policy, use UFW’s dry-run mode:

sudo ufw --dry-run allow 8080/tcp

Inspect the active rules and their status:

sudo ufw status

The listener and firewall rule must use the same protocol and port. A web server listening on TCP 8080 is not made reachable by allowing UDP 8080, and allowing TCP 80 does not permit TCP 8080.

If UFW is inactive, another firewall may still protect the machine. Do not disable a firewall merely to test the site; identify which layer is enforcing policy and add the narrow rule there.

Permit the port outside the Ubuntu host

Cloud servers

Cloud providers often place an additional security group, network ACL, or virtual firewall in front of the instance. Add an inbound rule for TCP 8080, restricted to the source ranges you actually need. The instance’s UFW rule and the provider rule are cumulative: both must permit the connection.

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

Home or office servers behind a router

Create a port-forwarding or NAT rule that maps the router’s public TCP 8080 to the Ubuntu machine’s private IP and TCP 8080. Reserve the server’s private address so the forwarding target does not change after a DHCP lease renewal. If the internet connection uses carrier-grade NAT, inbound forwarding may be unavailable without a provider-supported public address or tunnel.

Upstream provider restrictions

Some hosting or network providers block uncommon inbound ports. If local tests pass and every rule is correct but outside clients still time out, check the provider’s allowed-port policy rather than repeatedly changing Apache2 or nginx.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Test from the server, then from another network

Local test

First verify that the service answers on the loopback interface:

curl -I http://127.0.0.1:8080

A successful response header proves that a process accepted the local TCP connection and returned an HTTP response. It does not prove that the service is bound to the public interface or reachable through external firewalls.

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

If the local request fails, check the service-specific configuration test, the systemd service state, and the socket list:

sudo ss -ltnp | grep ':8080'

No matching listener generally means the service did not reload, is bound to a different port, or is restricted to another address.

Remote test

From a different network—such as a separate internet connection—request the public hostname and explicit port:

curl -I http://public-name.example:8080

Testing from outside the server avoids false positives caused by local routing or firewall exceptions. A browser test should use the same explicit URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Diagnose common symptoms

“Connection refused”

Refusal usually means nothing is listening on the requested address and port, or a firewall is actively rejecting it. Confirm the exact port in ss -ltnp, verify the Apache2 or nginx reload succeeded, and check that the listener is not limited to 127.0.0.1. Then inspect UFW and any upstream firewall.

Local curl works, remote curl times out

This pattern points away from the web application and toward network policy: UFW, a cloud security group, router NAT, an upstream provider block, or an incorrect public IP. Verify each layer in that order and confirm that DNS points to the address where the port is forwarded.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

A 404 or the wrong website appears

When an HTTP response arrives, the port is reachable; the remaining issue is usually site matching. For Apache2, check the enabled <VirtualHost *:8080> and ServerName. For nginx, check the listen 8080; declaration, the optional IPv6 listener, and server_name. Ensure the intended site is enabled and that the request hostname exactly matches its configuration.

The browser cannot connect by hostname but works by IP

Check DNS records, split-horizon DNS, and the address family being used. The URL must still include :8080; DNS supplies an address, not a non-default port. If the hostname resolves to IPv6 first, ensure nginx or Apache2 is listening and permitted on IPv6 as well.

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

Reload reports an address-in-use error

Another process has claimed the chosen port, or duplicate configuration files define the same listener. Use sudo ss -ltnp to identify the owner and search enabled Apache2 or nginx files for repeated Listen 8080 or listen 8080 declarations. Stop or reconfigure the conflicting service only after confirming it is safe to do so.

HTTP on a custom port is not HTTPS

Port selection does not encrypt traffic. HTTP on 8080 has the same confidentiality and integrity limitations as HTTP on 80. Ubuntu’s nginx guidance treats port 80 as a normal HTTP entry point and port 443, configured with certificates, as the production HTTPS endpoint.

If the site should be private or carry credentials, configure TLS and serve HTTPS on an appropriate TLS listener, commonly 443. Visitors would then use an https:// URL and the explicit custom port if you intentionally place TLS elsewhere, for example https://example.com:8443/. A certificate does not appear automatically merely because a port was changed.

When redirecting HTTP to HTTPS, define the behavior for both ports explicitly. A redirect on port 80 does not automatically cover 8080, and a request to an HTTP custom port will not be upgraded unless the corresponding server configuration issues the redirect.

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

Security and operational checklist

  • Choose a port that is not already bound and document why it is exposed.
  • Bind only to required interfaces when the service is not meant to be public.
  • Allow only TCP and only the selected port in UFW and upstream controls.
  • Restrict cloud or router source ranges where practical.
  • Keep Apache2, nginx, Ubuntu, application code, and dependencies updated.
  • Use HTTPS for authentication, payments, personal data, and administration.
  • Monitor logs for unexpected scans and repeated failed requests.
  • Retest after reboots to ensure the service, firewall rule, public address, and NAT mapping persist.

Apache2 and nginx at a glance

Configuration question Apache2 nginx
Primary port directive Listen in /etc/apache2/ports.conf listen in a server block
Site matching Virtual-host configuration, optionally with ServerName server_name plus listen selection
Apply a change Validate, then reload Apache2 Validate, then reload nginx
Typical role General-purpose web server with per-site virtual hosts Web server and reverse proxy with server blocks

End-to-end procedure

  1. Check the selected port with sudo ss -ltnp.
  2. For Apache2, set Listen 8080 in /etc/apache2/ports.conf and use <VirtualHost *:8080>; for nginx, set listen 8080; and the matching IPv6 listener when applicable.
  3. Run sudo apache2ctl configtest or sudo nginx -t.
  4. Reload the appropriate service with sudo systemctl reload apache2 or sudo systemctl reload nginx.
  5. Allow the port with sudo ufw allow 8080/tcp, optionally previewing it first with sudo ufw --dry-run allow 8080/tcp.
  6. Add the same TCP port to the cloud security group or router NAT rule if one exists.
  7. Verify locally using curl -I http://127.0.0.1:8080.
  8. Verify externally using curl -I http://public-name.example:8080, then give visitors the complete URL including :8080.

Once all four layers—listener, site matching, firewall, and network forwarding—agree, Ubuntu can serve the website reliably on a non-standard HTTP port. Treat that port as an address change only; encryption, certificate management, redirects, and access controls remain separate configuration decisions.

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 quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

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.