Follow
Ubuntu Linux

How to Install Consul Server on Ubuntu Linux

Richard
Written by
Richard
Jan 26, 2024 Updated Mar 19, 2026 4 min read
How to Install VMware Workstation Player on Ubuntu Linux
How to Install VMware Workstation Player on Ubuntu Linux

You install a Consul server on Ubuntu Linux to deploy HashiCorp’s service networking solution for managing distributed applications.

Consul automates network configuration, enables service discovery, and secures service-to-service communication, making it crucial for microservices and complex system architectures.

This tutorial walks you through setting up a single Consul server on Ubuntu 22.04 LTS, covering the essential steps to get it running.

⚡ Quick Answer

Update system packages, then download and install the Consul binary to /usr/local/bin. Create a dedicated Consul user and configure directories. Finally, set up a systemd service file to run and manage the Consul agent.

Prerequisites

  • A machine running Ubuntu Linux (18.04 or later)
  • Sudo privileges
  • Stable internet connection for software download

Update System Packages

Open up your terminal and begin by updating your package lists:

🐧Bash / Shell
sudo apt-get update

Then, upgrade your system packages to the latest versions:

🐧Bash / Shell
sudo apt-get upgrade

Download Consul

Fetch the latest version of Consul from the official HashiCorp releases page. You can do it with wget.

First, install wget if you do not have it already:

🐧Bash / Shell
sudo apt-get install wget unzip

Next, download the Consul zip archive. You can find the latest version from the link below:

💻Code
CONSUL_VERSION="1.17.2"
wget https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip

Replace "1.17.2" with the latest Consul version if there is a newer one available.

Install Consul

Unzip the Consul archive:

💻Code
unzip consul_${CONSUL_VERSION}_linux_amd64.zip

Move the Consul binary to your system’s PATH so that it can be executed from anywhere:

🐧Bash / Shell
sudo mv consul /usr/local/bin/

Verify the installation:

💻Code
consul --version

The command should output similar lines shown below;

💻Code
Consul v1.17.2
Revision 7736539d
Build Date 2024-01-22T16:55:18Z
Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)

Create a Consul User

For security reasons, it’s best not to run Consul as root. Create a new user for Consul:

🐧Bash / Shell
sudo useradd --system --home /etc/consul.d --shell /bin/false consul

Configure Consul

Create configuration directories for Consul:

🐧Bash / Shell
sudo mkdir --parents /opt/consul
sudo mkdir --parents /etc/consul.d

Grant the Consul user ownership of those directories:

🐧Bash / Shell
sudo chown --recursive consul:consul /opt/consul
sudo chown --recursive consul:consul /etc/consul.d

Create a basic configuration file by running the command below.

🐧Bash / Shell
sudo nano /etc/consul.d/consul.hcl

Then, please copy and paste the content below into the file and save it. Remember to replace the bind_addr and advertise_addr addresses with your server’s own.

💻Code
{
  "datacenter": "dc1",
  "data_dir": "/opt/consul",
  "log_level": "INFO",
  "server": true,
  "ui": true,
  "bind_addr": "192.168.128.2",
  "client_addr": "0.0.0.0",
  "advertise_addr": "192.168.128.2",
  "bootstrap_expect": 1
}

Create a Systemd Service File

You’ll now create a systemd service file to manage the Consul process by running the command below.

🐧Bash / Shell
sudo nano /etc/systemd/system/consul.service

Then, please copy and paste the content below into the file and save it.

💻Code
[Unit]
Description=Consul Service
After=network.target

[Service]
User=consul
Group=consul
ExecStart=/usr/local/bin/consul agent -config-dir=/etc/consul.d/
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

Next, reload the systemd daemon and enable the Consul service to run on system boot:

🐧Bash / Shell
sudo systemctl daemon-reload
sudo systemctl enable consul

Start and Verify the Consul Service

Start the Consul service:

🐧Bash / Shell
sudo systemctl start consul

Check the status of the service:

🐧Bash / Shell
sudo systemctl status consul

You should see similar lines as shown below.

💻Code
 consul.service - Consul Service
     Loaded: loaded (/etc/systemd/system/consul.service; enabled; preset: enabled)
     Active: active (running) since Fri 2024-01-26 08:17:23 CST; 1min 43s ago
   Main PID: 9990 (consul)
      Tasks: 8 (limit: 4571)
     Memory: 25.9M
        CPU: 1.255s
     CGroup: /system.slice/consul.service
             └─9990 /usr/local/bin/consul agent -config-dir=/etc/consul.d/

Access the Consul Web UI

Consul has a web UI that you can access from your browser. Since you’ve set up the server to bind to all client addresses with "client_addr": "0.0.0.0", you should access the UI at:

💻Code
http://<Your_Ubuntu_Machine_IP>:8500/ui/

Replace <Your_Ubuntu_Machine_IP> with the actual IP address of your Ubuntu machine.

Consul server web UI dashboard showing service networking and monitoring status
Consul server web UI dashboard showing service networking and monitoring status

That should do it!

Conclusion:

  • Consul by HashiCorp is a powerful tool for managing microservices, service meshes, and distributed systems. It provides automated network configurations, service discovery, and secure connectivity across any cloud or runtime environment.
  • Following the installation guide, you have successfully installed Consul on your Ubuntu server. This allows you to organize services, manage dependencies, and automate common networking tasks.
  • With Consul’s intuitive web UI and robust features, you are now ready to join other nodes to your cluster, configure service discovery, and set up service meshes to meet your organization’s specific requirements.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Upgrade Ubuntu Linux
Ubuntu Linux How to Upgrade Ubuntu Linux
How to Install Ubuntu Linux
Ubuntu Linux How to Install Ubuntu Linux
How to Connect Bluetooth Devices to Ubuntu
Ubuntu Linux How to Connect Bluetooth Devices to Ubuntu

No comments yet — be the first to share your thoughts!

Leave a Comment

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