Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober 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 Install HAProxy on Ubuntu 22.04 (Jammy)

Install HAProxy on Ubuntu 22.04 (Jammy) with APT, configure a working HTTP reverse proxy and round-robin backend pool, enable health checks, validate safely, and resolve common firewall, binding, and service errors.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install HAProxy on Ubuntu 22.04 with sudo apt update followed by sudo apt install haproxy. The Jammy package provides the community HAProxy load-balancing reverse proxy. After installation, edit /etc/haproxy/haproxy.cfg, validate the configuration, restart the service, and enable it at boot. The example below publishes an HTTP listener on port 80 and distributes requests between two backend web servers.

What you are installing

Ubuntu 22.04 (Jammy) distributes HAProxy as the haproxy package. It is a reverse proxy and load balancer: clients connect to HAProxy, and HAProxy forwards those requests to one of the backend servers you define. The package is managed by systemd, with the service configured to start from /etc/haproxy/haproxy.cfg. Its unit is ordered after network-online.target and installed in multi-user.target, so it can start automatically during a normal multi-user boot.

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.

The package index observed for Ubuntu 22.04 listed version 2.4.30-0ubuntu0.22.04.2. That is a package version identifier from the Ubuntu security archive at the time of observation, not a permanent version promise; later security updates can change it.

Before you begin

  • Use an Ubuntu 22.04 (Jammy) host with administrative access through sudo.
  • Know the IP address and listening port of every backend server. The sample uses 10.0.0.11:80 and 10.0.0.12:80; replace them with addresses reachable from the HAProxy host.
  • Choose a frontend port that is not already occupied. The example binds TCP port 80 on every local interface.
  • Permit traffic in both directions: clients must be able to reach the frontend port, and the HAProxy host must be able to reach each backend port.
  • Have a maintenance window if another service already uses the configuration file or port you need.

Check the operating-system release before changing packages:

#1 Best Overall
Alta Labs Route10 | 10 Gig Multi-WAN Router | High-Performance Qualcomm Quad-Core Hardware-Accelerated VPN Router | 2 10 Gbps SFP+ and 4 2.5 Gbps Ports | Real-Time Stats | Load Balancing | 40W PoE+
  • Professional 10Gbps Wired Routing – Route10 is a high-performance 10 Gigabit wired router designed for advanced home, business, and enterprise networks; it does not broadcast Wi-Fi, and wireless coverage requires pairing with one or multiple Wi-Fi access points such as ceiling, wall, or outdoor access points for full network coverage.
  • Quad-Core Qualcomm Network Accelerator for High Throughput – Powered by a high-performance quad-core Qualcomm processor with hardware-accelerated networking, the Route10 delivers fast packet processing, low latency, and consistent multi-gigabit performance for routing, firewall rules, VPN traffic, VLAN segmentation, and high-bandwidth network workloads without bottlenecks.
  • Integrated PoE+ Output to Power Network Devices – Select Ethernet ports provide Power over Ethernet Plus (PoE+) support, allowing the router to power compatible access points, network devices, or edge hardware directly through the Ethernet cable, reducing the need for additional power adapters or injectors.
  • Enterprise-Grade Routing, Firewall, and Network Control – Supports advanced routing features including VLAN tagging, QoS traffic prioritization, NAT port forwarding, firewall rules, DHCP services, and professional network segmentation for secure, reliable, and scalable wired network deployments.
  • Real-Time Network Monitoring and Traffic Visibility – Provides live network statistics and real-time monitoring of bandwidth usage, connected devices, WAN and LAN traffic, and system performance, allowing network administrators to quickly identify issues, optimize traffic flow, and maintain stable, high-performance wired networks.
. /etc/os-release && echo "$PRETTY_NAME"

The output should identify Ubuntu 22.04. If the host is another Ubuntu release, use instructions and package availability for that release instead of assuming Jammy behavior.

Install HAProxy from Ubuntu’s Jammy repository

  1. Refresh package metadata.
    sudo apt update

    This downloads current package indexes, including security updates available to the configured Ubuntu 22.04 repositories.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Install the community package.
    sudo apt install haproxy

    Accept the proposed dependency changes when prompted. Ubuntu describes this package as a load-balancing reverse proxy.

  3. Confirm the installed binary.
    haproxy -v

    The displayed version depends on the Jammy package revision currently available to your configured repositories. Do not treat the observed 2.4.30-0ubuntu0.22.04.2 value as a requirement for every installation.

Understand the service and configuration paths

The main configuration file is /etc/haproxy/haproxy.cfg. The Ubuntu systemd unit starts HAProxy with that path, so edits elsewhere do not affect the packaged service unless you create a separate service definition.

Make a rollback copy before editing:

sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bak

Keep the backup outside any automated overwrite process and update it after you have a known-good configuration. HAProxy will not safely apply a malformed file; validate the file before every restart.

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

Build a minimal HTTP reverse proxy and load balancer

Open the packaged configuration with a root-capable editor:

Rank #2
Ubiquiti UXG-Enterprise 25G Independent Gateway featuring Multi-WAN Load Balancing, 12.5 Gbps IDS/IPS Routing, and Redundant Hot-Swap Power Supplies
  • Compatible management via CloudKey, Official UniFi Hosting, or UniFi Network Server running version 8.3.32 or newer
  • Ensures continuous connection through Shadow Mode High Availability featuring automatic failover (VRRP)
  • Delivers 12.5 Gbps routing performance equipped with IDS/IPS capabilities
  • Offers license-free, real-time decryption and inspection of encrypted traffic using NeXT AI Inspection*
  • Features 25G SFP28, 10G SFP+, and 2.5 GbE RJ45 ports where two interfaces can be reconfigured as WAN connections
sudo editor /etc/haproxy/haproxy.cfg

For a minimal HTTP setup, define one frontend and one backend:

frontend http
    bind *:80
    mode http
    default_backend web-backend

backend web-backend
    balance roundrobin
    server web1 10.0.0.11:80 check
    server web2 10.0.0.12:80 check

How the frontend works

  • frontend http names the client-facing section. The name is an internal label and can be changed.
  • bind *:80 listens on port 80 on all local IPv4 interfaces. Replace * with a specific local address when you intentionally want to limit exposure.
  • mode http tells HAProxy to process the listener as HTTP rather than as an opaque TCP stream.
  • default_backend web-backend sends requests that do not match a more specific routing rule to the backend section with that name.

How the backend works

  • backend web-backend defines the pool of destination servers.
  • balance roundrobin selects servers in turn, distributing successive requests across the available members.
  • Each server line has an HAProxy name, an address and port, and the check option. The names web1 and web2 are labels used in status output; they do not need to match DNS names.

Use the exact addresses and ports your applications expose. A private address such as 10.0.0.11 is only an example. HAProxy must be able to route to it from the proxy host, and the backend firewall must permit that connection.

Use health checks so failed servers leave rotation

Appending check to a server line enables an active health check. HAProxy’s basic TCP-layer check attempts to connect to the server (or send an HTTP request at a regular interval, depending on the check configuration). A server that answers the connection handshake is considered available; a failed server is removed from load-balancing rotation until it recovers. This prevents new requests from being sent to a machine that is unreachable.

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.

A TCP check confirms reachability of the configured port, not that your application has returned a correct page. If an application needs a deeper test, you must define an HTTP health-check path and expected behavior appropriate to that application; do not assume that a successful TCP handshake proves application health.

Validate the file before applying it

Run HAProxy’s configuration check as root so it can read every referenced file:

sudo haproxy -c -f /etc/haproxy/haproxy.cfg

A successful check reports that the configuration file is valid. If HAProxy reports a line number, correct that line and run the command again. Typical causes include a misspelled keyword, an invalid address or port, an unclosed section edit, or a directive placed in the wrong section. Do not restart while the check is failing.

Start, enable and inspect the service

  1. Restart HAProxy after a successful validation.
    sudo systemctl restart haproxy
  2. Inspect the unit and its recent result.
    sudo systemctl status haproxy

    Look for an active (running) state. If the service failed, the status output normally includes the immediate reason.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    Rank #3
    Titan Networx - Hardwired Router TNGR-4000
    • Hardwired Router
    • Titan Networx
    • High performance router
    • managed switch
    • integrated router
  3. Enable startup at boot.
    sudo systemctl enable haproxy

    The packaged unit is installed for multi-user.target, so enabling it makes HAProxy start during subsequent normal boots.

Enabling a service and starting it are separate operations. restart applies the configuration now; enable records the boot-time relationship. Use both when this host should provide the proxy after a reboot.

Open the network paths HAProxy needs

Port 80 must be reachable from clients, and the backend addresses and ports must be reachable from the HAProxy host. If Ubuntu’s uncomplicated firewall (UFW) is enabled, allow the frontend port according to your site’s policy:

sudo ufw allow 80/tcp

That command changes the host firewall; it does not configure upstream cloud security groups, network ACLs, hardware firewalls, or the backend servers’ own firewalls. Permit only the source ranges and ports required by your deployment. If another local process already owns port 80, HAProxy cannot bind to it; stop or reconfigure that process, or select a different frontend port.

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.

Test the listener and the backend path

From the HAProxy host, first test the local listener:

curl -I http://127.0.0.1/

From a client that should use the service, send a request to the HAProxy host’s address rather than directly to a backend. A response demonstrates that the listener accepted the connection and selected an available backend. If your backend application does not implement HEAD, use a normal request instead:

curl -v http://PROXY_ADDRESS/

Replace PROXY_ADDRESS with the proxy’s reachable address; it is a placeholder for a real hostname or IP and should not be copied literally.

When no backend is available, HAProxy can accept the frontend connection but has nowhere to forward it. Check each backend directly from the proxy host using its real address and port, then inspect the service status and firewall rules on that backend.

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

Troubleshoot the common installation failures

Symptom What to check Corrective action
apt install haproxy cannot find the package Release identification and package indexes Confirm the machine is Ubuntu 22.04 and run sudo apt update. Check that the configured Jammy repositories are reachable and enabled.
Validation reports a syntax or parsing error The line named in haproxy -c output Fix the directive, section placement, address, or port, then rerun sudo haproxy -c -f /etc/haproxy/haproxy.cfg. Restart only after it succeeds.
Service fails with an address-in-use or bind error Another process listening on the frontend port Identify the process with a socket-listening tool such as sudo ss -ltnp | grep ':80'. Reconfigure that process, stop it if appropriate, or change the HAProxy bind port.
Service is running but every backend is unavailable Backend IP, port, route, and firewall; whether the application is listening Test the real backend endpoint from the HAProxy host. Correct the server line or permit the backend connection. A failed check server is intentionally removed from rotation.
Clients time out while local tests work UFW, cloud security groups, upstream firewalls, and the address used in bind Permit the client-to-proxy port on every network layer and ensure the client is using an address on which HAProxy is listening.
HAProxy exits immediately after a change Service status and the system journal Run sudo systemctl status haproxy and review sudo journalctl -u haproxy. Restore the backup if necessary, validate it, and restart.

Modify the example safely

Adding or removing backend servers

Add another server line inside web-backend when a new server is reachable and serves the same traffic:

    server web3 10.0.0.13:80 check

Remove a server line only after traffic has been drained or redirected according to your application’s needs. Every edit follows the same sequence: save the file, validate it, restart HAProxy, and inspect the service.

Changing the frontend port

Change bind *:80 to another free port when port 80 is reserved by another service. Update firewall rules and client URLs at the same time. The backend port does not have to equal the frontend port; they are independent endpoints.

Choosing a specific bind address

Binding to * exposes the listener on every matching local interface. A specific address limits the listener to that interface, which is useful when the host has separate public and private networks. The chosen address must exist on the host when HAProxy starts.

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

Community package versus HAProxy Enterprise

These installation steps describe Ubuntu’s free community package. HAProxy Enterprise uses a separate licensed Ubuntu 22.04 repository path and requires an enterprise key, so its repository setup and entitlement process are different.

Area Ubuntu community package HAProxy Enterprise
Installation source Ubuntu’s Jammy package repositories; install with sudo apt install haproxy. Separate licensed Ubuntu 22.04 repository setup.
License and entitlement Normal Ubuntu community-package flow; no enterprise key is required for this procedure. Requires a provided enterprise license key.
Updates Ubuntu package revisions and security updates, which can change the installed version. Enterprise repository and release channel.
Support and modules Community distribution and its packaged feature set. Enterprise support entitlement and enterprise modules, subject to the purchased edition.
Compatibility consideration Designed for the standard Jammy package workflow described here. Verify the licensed repository and edition support for Ubuntu 22.04 before deployment.

For a normal Ubuntu 22.04 installation, the community package is the straightforward default. Do not add enterprise repository instructions or keys unless you have that separate entitlement.

Updating or removing the package

When Ubuntu publishes a newer Jammy revision, refresh metadata and apply normal package updates according to your maintenance policy. Before an update, keep a copy of the working configuration and plan a validation and service check afterward:

sudo apt update
sudo apt install --only-upgrade haproxy
sudo haproxy -c -f /etc/haproxy/haproxy.cfg
sudo systemctl restart haproxy
sudo systemctl status haproxy

If you no longer need HAProxy, remove the package through APT. Removing software does not automatically redesign firewall rules, DNS, client configuration, or backend services; clean those dependencies separately and deliberately.

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

Quick Recap

Bestseller No. 2
Ubiquiti UXG-Enterprise 25G Independent Gateway featuring Multi-WAN Load Balancing, 12.5 Gbps IDS/IPS Routing, and Redundant Hot-Swap Power Supplies
Ubiquiti UXG-Enterprise 25G Independent Gateway featuring Multi-WAN Load Balancing, 12.5 Gbps IDS/IPS Routing, and Redundant Hot-Swap Power Supplies
Delivers 12.5 Gbps routing performance equipped with IDS/IPS capabilities; Includes two hot-swappable power supplies to guarantee power redundancy
$2,014.24
Bestseller No. 3
Titan Networx - Hardwired Router TNGR-4000
Titan Networx - Hardwired Router TNGR-4000
Hardwired Router; Titan Networx; High performance router; managed switch; integrated router
$316.00
sudo apt remove haproxy

Installation checklist

  • The host identifies as Ubuntu 22.04 (Jammy).
  • sudo apt update completed without repository errors.
  • sudo apt install haproxy completed and haproxy -v reports an installed binary.
  • /etc/haproxy/haproxy.cfg contains a frontend, a default backend, a balancing method, and reachable server lines.
  • Each backend has check when active TCP health checks are appropriate.
  • sudo haproxy -c -f /etc/haproxy/haproxy.cfg succeeds before restart.
  • sudo systemctl restart haproxy leaves the unit active.
  • sudo systemctl enable haproxy is set if the proxy must return after reboot.
  • Client-to-frontend and proxy-to-backend firewall paths are permitted.
  • A request to the proxy address reaches an available backend.

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
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.