Skip to content
Follow
Ubuntu Linux

How to Install Consul Server on Ubuntu Linux

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

Consul is a service discovery tool made by HashiCorp that helps different parts of your software find and talk to each other across a network. Setting up a single Consul server on Ubuntu 22.04 LTS takes only a few steps.

Advertisement

You download the software, create a system user, and write a basic configuration file to get the service running on your machine.

⚡ 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.

Advertisement

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:

sudo apt-get update

Then, upgrade your system packages to the latest versions:

sudo apt-get upgrade

Download Consul

To download Consul for your Ubuntu system, you need to grab the official zip file from the HashiCorp website using terminal tools. You can install the required tools and fetch the package by running sudo apt-get install wget unzip, which prepares your machine to install Consul server Ubuntu without missing dependencies.

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

Advertisement
sudo apt-get install wget unzip

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

CONSUL_VERSION="1.17.2"
wget https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
⚠️WarningReplace "1.17.2" with the latest Consul version if there is a newer one available.

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

Install Consul

Installing Consul on your Ubuntu machine requires extracting the downloaded zip archive and moving the binary file into your system path. This process makes the command available globally so you can verify the installation and successfully install Consul server Ubuntu from any terminal window.

Advertisement
unzip consul_${CONSUL_VERSION}_linux_amd64.zip

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

sudo mv consul /usr/local/bin/

Verify the installation:

consul --version

The command should output similar lines shown below;

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:

Advertisement
sudo useradd --system --home /etc/consul.d --shell /bin/false consul

Configure Consul

Configuring Consul requires setting up dedicated storage directories for configuration files and data, then assigning proper ownership to a dedicated system user. These steps ensure that when you install Consul server Ubuntu, the application has the right permissions to read its settings and run securely.

sudo mkdir --parents /opt/consul
sudo mkdir --parents /etc/consul.d

Grant the Consul user ownership of those directories:

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.

sudo nano /etc/consul.d/consul.hcl
⚠️WarningThen, 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.

Advertisement
{
  "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

Creating a systemd service file lets Ubuntu manage Consul as a background process that starts automatically when the machine boots. You set this up by opening a new service configuration file in the nano editor and pasting the required startup parameters to properly install Consul server Ubuntu.

sudo nano /etc/systemd/system/consul.service

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

[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:

sudo systemctl daemon-reload
sudo systemctl enable consul

Start and Verify the Consul Service

Starting and verifying the Consul service ensures the application is running correctly and enabled to start on boot. You can launch the daemon and check its current health by running standard systemctl commands, which confirms you have successfully completed your goal to install Consul server Ubuntu.

Advertisement
sudo systemctl start consul

Check the status of the service:

sudo systemctl status consul

You should see similar lines as shown below.

 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

Accessing the Consul web UI gives you a visual dashboard to manage your cluster and check service health directly in your browser. You open this interface by typing your server address and port 8500 into the URL bar after you finish your setup to install Consul server Ubuntu.

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

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

Advertisement
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.

Advertisement

📚 Related Tutorials

How to Install WildFly on Ubuntu Linux
Ubuntu Linux How to Install WildFly on Ubuntu Linux
How to Install Chatwoot on Ubuntu Linux
Ubuntu Linux How to Install Chatwoot on Ubuntu Linux
How to Setup Fail2ban on Ubuntu Linux
Ubuntu Linux How to Setup Fail2ban on Ubuntu Linux
Working with Sudo and Su Commands in Ubuntu Linux
Ubuntu Linux Working with Sudo and Su Commands in Ubuntu Linux

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

Leave a Comment

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