Install Zabbix Agent on Ubuntu & RHEL and Connect to Server

A Zabbix server with nothing connected to it is a pretty expensive way to monitor one machine. The useful part starts when you put an agent on your other servers and they show up in the frontend with a green ZBX badge, sending CPU, memory, disk and network numbers every minute.

Installing the agent itself takes about thirty seconds. Getting it to actually talk to the server is where people lose an afternoon. The agent ships with a config that only trusts 127.0.0.1, a hostname that literally says “Zabbix server”, and on RHEL there’s a firewall and an EPEL package conflict waiting for you too.

This guide connects two real clients to a Zabbix 7.4 server: an Ubuntu 26.04 machine added by hand in the frontend, and a RHEL 9 machine that registers itself automatically. Then the Ubuntu link gets PSK encryption. Every command and error below was captured from that setup. If you don’t have a server yet, start with installing the Zabbix server, database and frontend on Ubuntu and come back.

The lab setup

Three machines on one LAN:

  • Zabbix server: 192.168.100.71, Ubuntu 26.04, Zabbix 7.4.15
  • ubuntu-client: 192.168.100.66, Ubuntu 26.04.1 LTS
  • app1: 192.168.100.65, RHEL 9.6

Two ports matter, and it helps to know which way each one goes before you touch a firewall:

  • 10050/tcp, server to agent. Passive checks. The server connects to the agent and asks for a value. This has to be open on every client.
  • 10051/tcp, agent to server. Active checks and autoregistration. The agent connects to the server, gets its list of checks, then pushes results. This has to be open on the server.

Most setups use both, and that’s what we’ll do here.

Zabbix agent or agent 2?

Go with agent 2 (zabbix-agent2) unless you have a reason not to. It’s the newer Go-based agent, it handles checks concurrently, and it has plugins for things like Docker, MySQL and PostgreSQL. The classic C agent (zabbix-agent) is still supported and slightly lighter, which can matter on tiny or ancient boxes. Both speak the same protocol on the same port, and the config options covered here are identical in both.

Version-wise, match the agent to the server’s major version when you can. Zabbix supports older agents talking to a newer server, but not the other way round, so don’t put an 8.0 agent against a 7.4 server. We’re using 7.4.15 everywhere.

Part 1: Install Zabbix agent 2 on Ubuntu

Add the Zabbix repository

Ubuntu’s own archive carries an older Zabbix build, so use the official repo. Grab the release package for your Ubuntu version (swap 26.04 for 24.04 or 22.04 if that’s what you run):

lsb_release -a
Distributor ID:	Ubuntu
Description:	Ubuntu 26.04.1 LTS
Release:	26.04
Codename:	resolute

wget https://repo.zabbix.com/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.4+ubuntu26.04_all.deb
2026-10-05 00:22:46 URL:https://repo.zabbix.com/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.4+ubuntu26.04_all.deb [7984/7984] -> "zabbix-release_latest_7.4+ubuntu26.04_all.deb" [1]

sudo dpkg -i zabbix-release_latest_7.4+ubuntu26.04_all.deb
Selecting previously unselected package zabbix-release.
Preparing to unpack zabbix-release_latest_7.4+ubuntu26.04_all.deb ...
Unpacking zabbix-release (1:7.4-4+ubuntu26.04) ...
Setting up zabbix-release (1:7.4-4+ubuntu26.04) ...

sudo apt update

Check that apt will pull the agent from Zabbix and not from Ubuntu:

apt-cache policy zabbix-agent2
zabbix-agent2:
  Installed: (none)
  Candidate: 1:7.4.15-1+ubuntu26.04
  Version table:
     1:7.4.15-1+ubuntu26.04 500
        500 https://repo.zabbix.com/zabbix/7.4/stable/ubuntu resolute/main amd64 Packages

Install the agent

sudo apt install -y zabbix-agent2
...
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Setting up zabbix-agent2 (1:7.4.15-1+ubuntu26.04) ...
Created symlink '/etc/systemd/system/multi-user.target.wants/zabbix-agent2.service' → '/usr/lib/systemd/system/zabbix-agent2.service'.

zabbix_agent2 -V | head -1
zabbix_agent2 (Zabbix) 7.4.15

Two packages, done. Don’t celebrate yet though.

Why the default config doesn’t work

Here are the three lines that decide whether this agent will ever talk to your server, straight after install:

grep -nE "^(Server|ServerActive|Hostname)=" /etc/zabbix/zabbix_agent2.conf
82:Server=127.0.0.1
137:ServerActive=127.0.0.1
148:Hostname=Zabbix server

All three are wrong for a client machine. The package is configured as if the agent sits on the Zabbix server itself. Leave it like that and try polling it from the real server, and you get this:

# on the Zabbix server
zabbix_get -s 192.168.100.66 -k agent.ping
zabbix_get [26211]: Get value error: cannot read from socket: [104] Connection reset by peer

The agent log on the client spells out exactly what happened:

sudo tail -n 3 /var/log/zabbix/zabbix_agent2.log
2026/10/05 00:23:24.003935 [101] cannot connect to [127.0.0.1:10051]: dial tcp :0->127.0.0.1:10051: connect: connection refused
2026/10/05 00:23:24.003962 [101] sending of heartbeat message for [Zabbix server] started to fail
2026/10/05 00:23:34.117288 connection from "192.168.100.71" rejected, allowed hosts: "127.0.0.1"

Two problems in three lines. Active checks go to 127.0.0.1:10051, where no server is listening. And the passive request from 192.168.100.71 got rejected because the allowlist only has 127.0.0.1. That “Connection reset by peer” on the server side is just the agent hanging up on a client it doesn’t trust.

The Hostname=Zabbix server line is sneakier. Fix the IPs but forget the hostname, and this machine will send its active check data in under the name of your Zabbix server’s own host. Two machines reporting as one. It won’t throw an error. You’ll just get odd graphs.

Configure Server, ServerActive and Hostname

Open the config:

sudo nano /etc/zabbix/zabbix_agent2.conf

And change those three lines:

Server=192.168.100.71
ServerActive=192.168.100.71
Hostname=ubuntu-client

What each one actually does:

  • Server is the allowlist for passive checks. Only IPs listed here can query the agent on port 10050. Comma-separate if you have several servers or a proxy.
  • ServerActive is where the agent sends active checks. Add :port if your server doesn’t listen on 10051.
  • Hostname must match the Host name you’ll give this machine in the Zabbix frontend, character for character. It’s case-sensitive.

If you’d rather not hard-code the name, comment out Hostname and set HostnameItem=system.hostname, and the agent will use the machine’s real hostname. Handy when you bake the config into an image or push it with Ansible.

Confirm, restart and enable:

grep -nE "^(Server|ServerActive|Hostname)=" /etc/zabbix/zabbix_agent2.conf
82:Server=192.168.100.71
137:ServerActive=192.168.100.71
148:Hostname=ubuntu-client

sudo systemctl restart zabbix-agent2
sudo systemctl enable zabbix-agent2
Synchronizing state of zabbix-agent2.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable zabbix-agent2

systemctl status zabbix-agent2 --no-pager
● zabbix-agent2.service - Zabbix Agent 2
     Loaded: loaded (/usr/lib/systemd/system/zabbix-agent2.service; enabled; preset: enabled)
     Active: active (running) since Mon 2026-10-05 00:23:47 UTC; 1s ago
   Main PID: 375 (zabbix_agent2)
      Tasks: 7 (limit: 3259)
     Memory: 8.2M (peak: 8.3M)
        CPU: 110ms

sudo ss -tlnp | grep 10050
LISTEN 0      4096               *:10050            *:*    users:(("zabbix_agent2",pid=375,fd=7))

8 MB of memory. The agent really is light.

Open port 10050 in UFW

If UFW is on, don’t open 10050 to the whole world. Only the Zabbix server needs it:

sudo ufw allow from 192.168.100.71 to any port 10050 proto tcp
Rules updated

Test from the Zabbix server with zabbix_get

This is the step most guides skip, and it’s the one that saves the most time. Before you touch the web UI, prove the server can reach the agent from the command line. Install zabbix-get on the server:

# on the Zabbix server
sudo apt install -y zabbix-get
Setting up zabbix-get (1:7.4.15-1+ubuntu26.04)...

zabbix_get -s 192.168.100.66 -k agent.ping
1
zabbix_get -s 192.168.100.66 -k agent.hostname
ubuntu-client
zabbix_get -s 192.168.100.66 -k agent.version
7.4.15

1 from agent.ping means the network path, firewall and Server= allowlist are all fine. agent.hostname shows exactly what to type in the frontend. If zabbix_get works and the frontend still shows a red badge, the problem is in the host config in the UI, not on the client. That one split cuts your troubleshooting in half.

Part 2: Install Zabbix agent 2 on RHEL 9

Same idea, a few different traps. These steps work the same on Rocky Linux, AlmaLinux and Oracle Linux 9.

Add the Zabbix repository

cat /etc/redhat-release
Red Hat Enterprise Linux release 9.6 (Plow)

sudo rpm -Uvh https://repo.zabbix.com/zabbix/7.4/release/rhel/9/noarch/zabbix-release-latest-7.4.el9.noarch.rpm
warning: /var/tmp/rpm-tmp.vULQCN: Header V4 RSA/SHA512 Signature, key ID b5333005: NOKEY
Retrieving https://repo.zabbix.com/zabbix/7.4/release/rhel/9/noarch/zabbix-release-latest-7.4.el9.noarch.rpm
Verifying...                          ########################################
Preparing...                          ########################################
Updating / installing...
zabbix-release-7.4-3.el9              ########################################

sudo dnf clean all
41 files removed

The NOKEY warning is normal. dnf imports the Zabbix GPG key the first time you install from the repo.

The EPEL trap: exclude Zabbix packages from EPEL

If EPEL is enabled (and on most RHEL boxes it is), look at what dnf thinks the newest zabbix-agent is:

dnf -q list --available zabbix-agent
Available Packages
zabbix-agent.x86_64              1:6.0.47-1.el9               ol9_developer_EPEL

Zabbix 6.0. The official repo has 7.4.15 sitting right there, but the EPEL build carries an epoch (1:), and an epoch beats any version number in RPM’s comparison. So dnf install zabbix-agent quietly installs a two-major-versions-old agent from EPEL. The Zabbix docs mention this, most tutorials don’t.

Fix it by telling EPEL to stay out of Zabbix packages. Add excludepkgs=zabbix* under the EPEL section of its repo file. On RHEL, Rocky and Alma that’s the [epel] section in /etc/yum.repos.d/epel.repo. On this box the EPEL repo is Oracle’s, so it looks like this:

grep -A1 '^[ol9_developer_EPEL]' /etc/yum.repos.d/oracle-epel-ol9.repo
[ol9_developer_EPEL]
excludepkgs=zabbix*

dnf -q list --available zabbix-agent zabbix-agent2
Available Packages
zabbix-agent.x86_64                  7.4.15-release1.el9                  zabbix
zabbix-agent2.x86_64                 7.4.15-release1.el9                  zabbix

Both now come from the zabbix repo at 7.4.15.

Install the agent

sudo dnf install -y zabbix-agent2
Installing:
 zabbix-agent2       x86_64       7.4.15-release1.el9        zabbix       6.5 M
...
Importing GPG key 0xB5333005:
 Userid     : "Zabbix LLC (Apr 2024) <packager@zabbix.com>"
 Fingerprint: 4C3D 6F2C C75F 5146 754F C374 D913 219A B533 3005
...
  Installing       : zabbix-agent2-7.4.15-release1.el9.x86_64               1/1
Complete!

zabbix_agent2 -V | head -1
zabbix_agent2 (Zabbix) 7.4.15

One difference from Ubuntu: on RHEL the service is installed but not started. Red Hat’s packaging policy is not to start services on install.

systemctl is-active zabbix-agent2
inactive

Configure the agent for autoregistration

This host gets added to Zabbix automatically, so the config has one extra line, HostMetadata. It’s a free-text tag the agent sends when it first contacts the server, and an autoregistration action on the server can match on it. More on that in a minute.

sudo nano /etc/zabbix/zabbix_agent2.conf
Server=192.168.100.71
ServerActive=192.168.100.71
Hostname=app1
HostMetadata=linux-autoreg
grep -nE "^(Server|ServerActive|Hostname|HostMetadata)=" /etc/zabbix/zabbix_agent2.conf
82:Server=192.168.100.71
137:ServerActive=192.168.100.71
148:Hostname=app1
167:HostMetadata=linux-autoreg

sudo systemctl enable --now zabbix-agent2
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent2.service → /usr/lib/systemd/system/zabbix-agent2.service.

systemctl status zabbix-agent2 --no-pager
● zabbix-agent2.service - Zabbix Agent 2
     Loaded: loaded (/usr/lib/systemd/system/zabbix-agent2.service; enabled; preset: disabled)
     Active: active (running) since Mon 2026-10-05 05:30:37 PKT; 37ms ago
    Process: 108499 ExecStartPre=/usr/sbin/zabbix_agent2 -T -c $CONFFILE (code=exited, status=0/SUCCESS)
   Main PID: 109076 (zabbix_agent2)

Notice the ExecStartPre line. The RHEL unit runs a config syntax test (-T) before starting, so a typo in the config makes the service refuse to start rather than start half-broken. If systemd units are new territory, that’s a nice pattern to steal for your own services.

Open port 10050 in firewalld

Test from the server right now and it fails, differently from the Ubuntu error:

# on the Zabbix server
zabbix_get -s 192.168.100.65 -k agent.ping
zabbix_get [26354]: Get value error: cannot connect to [[192.168.100.65]:10050]: connection error (POLLERR,POLLHUP)

“Cannot connect” with POLLERR means the TCP connection never got through. That’s firewalld, which is on by default on RHEL and blocks 10050. Conveniently, firewalld already ships a service definition for the agent:

firewall-cmd --info-service=zabbix-agent
zabbix-agent
  ports: 10050/tcp
  ...

sudo firewall-cmd --permanent --add-service=zabbix-agent
success
sudo firewall-cmd --reload
success
sudo firewall-cmd --list-services
cockpit dhcpv6-client ssh zabbix-agent

Try again:

# on the Zabbix server
zabbix_get -s 192.168.100.65 -k agent.ping
1
zabbix_get -s 192.168.100.65 -k agent.hostname
app1
zabbix_get -s 192.168.100.65 -k vfs.fs.size[/,pfree]
81.856198

That last one is the percentage of free space on /, pulled live from the client. On SELinux, the stock Zabbix agent works fine in enforcing mode with the built-in templates. You only need custom SELinux policy if you start running UserParameter scripts that touch unusual paths or run remote commands.

“host [app1] not found” is expected (for now)

Peek at the RHEL agent log at this point and it looks like something is broken:

sudo tail -n 3 /var/log/zabbix/zabbix_agent2.log
2026/10/05 05:30:37.083265 Zabbix Agent2 hostname: [app1]
2026/10/05 05:30:39.004063 [101] no active checks on server [192.168.100.71:10051]: host [app1] not found
2026/10/05 05:30:39.004088 [101] active checks on server started to fail

Nothing is wrong. The agent reached the server on 10051 fine. The server just doesn’t have a host called app1 yet. That message goes away the moment the host exists in Zabbix, either because you add it by hand or because autoregistration creates it. Same goes for the Ubuntu client until the next step.

Add the Ubuntu host in the Zabbix frontend

Now the server side. In the web UI, go to Data collection > Hosts and click Create host. Fill in:

  • Host name: ubuntu-client. Must match Hostname= in the agent config exactly.
  • Templates: Linux by Zabbix agent. This gives you CPU, memory, disks, filesystems, network interfaces and about 80 items out of the box.
  • Host groups: Linux servers, or whatever group makes sense for you.
  • Interfaces: click Add > Agent, enter the client’s IP 192.168.100.66, port 10050.
Zabbix 7.4 New host form: host name ubuntu-client, Linux by Zabbix agent template, Linux servers group, agent interface 192.168.100.66 port 10050

Click Add. Within a minute or so, the server log confirms it’s polling the new host:

# on the Zabbix server
sudo grep ubuntu-client /var/log/zabbix/zabbix_server.log
 19967:20261005:053329.227 enabling Zabbix agent checks on host "ubuntu-client": interface became available

A note on templates: Linux by Zabbix agent uses passive checks, where the server polls the agent. There’s also Linux by Zabbix agent active, where the agent pushes everything. Use the active one when the server can’t reach the client (NAT, cloud instances behind a firewall you don’t control); then only port 10051 on the server needs to be open.

Let RHEL hosts register themselves (autoregistration)

Adding hosts by hand is fine for five machines. For fifty, or for auto-scaled cloud instances, you want them to show up on their own. That’s what autoregistration does: when an agent with active checks contacts the server and its host doesn’t exist, the server runs any matching autoregistration actions.

Go to Alerts > Actions > Autoregistration actions and click Create action. Give it a name and add one condition: Host metadata contains linux-autoreg. That’s the string we put in HostMetadata on app1.

Zabbix autoregistration action with condition Host metadata contains linux-autoreg

On the Operations tab, add three operations: Add host, Add to host groups: Linux servers, and Link templates: Linux by Zabbix agent.

Zabbix autoregistration operations: Add host, add to host group Linux servers, link template Linux by Zabbix agent

Save it, and you don’t touch app1 at all. Its agent retries active checks on its own schedule, and on the next attempt the server log shows the host appearing and getting polled:

# on the Zabbix server
 19936:20261005:053341.287 cannot send list of active checks to "192.168.100.65": host [app1] not found
 19967:20261005:053349.227 enabling Zabbix agent checks on host "app1": interface became available
 19967:20261005:053414.235 resuming Zabbix agent checks on host "app1": connection restored

Eight seconds from “not found” to being monitored. And the agent log on app1 agrees:

sudo tail -n 1 /var/log/zabbix/zabbix_agent2.log
2026/10/05 05:34:41.011988 [101] active checks on server are active again

Autoregistered hosts land in Discovered hosts as well as any groups your action adds, and the agent interface is created with the IP the connection came from. Two things to keep in mind: the metadata string is the only thing standing between “any agent on the network” and “a host in your Zabbix”, so use something less guessable than linux-autoreg in production, or pair autoregistration with PSK. The conditions can also match on hostname patterns, so you can route web-* and db-* machines to different groups and templates.

Encrypt agent traffic with PSK

By default, everything between server and agent crosses the network in plain text. On a trusted LAN that might be fine. Across a WAN, a cloud VPC, or any shared network, turn on encryption. A pre-shared key (PSK) is the easy way: no certificates, just a random key on both ends.

On the Ubuntu client, generate a 256-bit key and lock down the file:

openssl rand -hex 32 | sudo tee /etc/zabbix/zabbix_agent2.psk
46f9111b80955a9aa9d11046e79772f134e8743ff466c8cfcf728d4062c4b6b7
sudo chown zabbix:zabbix /etc/zabbix/zabbix_agent2.psk
sudo chmod 640 /etc/zabbix/zabbix_agent2.psk
ls -l /etc/zabbix/zabbix_agent2.psk
-rw-r----- 1 zabbix zabbix 65 Oct  5 00:34 /etc/zabbix/zabbix_agent2.psk

(That key belongs to a throwaway lab. Generate your own, obviously.)

Rather than editing the main config, drop a small file in zabbix_agent2.d/. The main config already includes everything in that directory, and your change survives package upgrades that replace zabbix_agent2.conf:

cat /etc/zabbix/zabbix_agent2.d/psk.conf
TLSConnect=psk
TLSAccept=psk
TLSPSKIdentity=PSK-ubuntu-client
TLSPSKFile=/etc/zabbix/zabbix_agent2.psk

sudo systemctl restart zabbix-agent2

TLSAccept=psk makes the agent refuse any unencrypted connection. Watch it happen from the server:

# on the Zabbix server
zabbix_get -s 192.168.100.66 -k agent.ping
zabbix_get [26635]: Get value error: cannot read from socket: [104] Connection reset by peer
# agent log on ubuntu-client
2026/10/05 00:34:37.005145 [101] cannot connect to [192.168.100.71:10051]: C0069BC3277F0000:error:0A000410:SSL routines:ssl3_read_bytes:ssl/tls alert handshake failure:../ssl/record/rec_layer_s3.c:918:SSL alert number 40
2026/10/05 00:34:42.645840 failed to read request from 192.168.100.71: cannot accept unencrypted connection

Both directions are failing now, which is exactly right: the server doesn’t know the key yet. zabbix_get can do PSK too, which proves the agent side works before you touch the UI:

# on the Zabbix server, key copied to a temp file
zabbix_get -s 192.168.100.66 -k agent.ping --tls-connect psk --tls-psk-identity PSK-ubuntu-client --tls-psk-file /tmp/ubuntu-client.psk
1

Now give the server the same identity and key. Open the host, go to the Encryption tab, set Connections to host to PSK, tick only PSK under Connections from host, and paste the identity and key:

Zabbix host Encryption tab: connections to host PSK, connections from host PSK, PSK identity PSK-ubuntu-client

Click Update, and within a minute the agent log flips back:

2026/10/05 00:35:35.021101 [101] sending of heartbeat message to [192.168.100.71:10051] is working again
2026/10/05 00:35:37.023989 [101] active check configuration update from [192.168.100.71:10051] is working again

The PSK identity isn’t secret, but it has to match exactly on both sides. A mismatch looks identical to a wrong key in the logs, so check spelling first.

Adding hosts with the Zabbix API (and an Apache gotcha)

Once you’re past a handful of hosts, scripting beats clicking. Zabbix has a JSON-RPC API for exactly that.

Get a token first

Every API call except login needs a token. The quickest way to get one is to log in through the API itself with user.login, using the same username and password as the web UI:

curl -s -H 'Content-Type: application/json-rpc' -d '{"jsonrpc":"2.0","method":"user.login","params":{"username":"Admin","password":"zabbix"},"id":1}' http://localhost/zabbix/api_jsonrpc.php
{"jsonrpc":"2.0","result":"2855345e60ee17ba70f2d40b2aee2832","id":1}

The result value is your token. In a script you don’t want to copy and paste it, so pull it straight into a variable with jq (sudo apt install jq if you don’t have it):

TOKEN=$(curl -s -H 'Content-Type: application/json-rpc' -d '{"jsonrpc":"2.0","method":"user.login","params":{"username":"Admin","password":"zabbix"},"id":1}' http://localhost/zabbix/api_jsonrpc.php | jq -r .result)
echo $TOKEN
e558f507eec58345d69dae3669376c0c

Every call below uses that $TOKEN. Swap in your real password, of course; if you still log in as Admin with zabbix, change that first.

This is a session token, and it ends when you log out or the session expires. For scripts and integrations that run unattended, create a permanent API token in the web UI instead: User settings > API tokens > Create API token. You can give it an expiry date and revoke it on its own, without touching a password, and it goes in the same Authorization: Bearer header.

The Apache gotcha

The token goes in an Authorization: Bearer header. On the Ubuntu 26.04 server from the server install guide, which runs the frontend on Apache with PHP-FPM, that header gets dropped before PHP ever sees it, so every authenticated call fails even with a valid token:

curl -s -H 'Content-Type: application/json-rpc' -H "Authorization: Bearer $TOKEN" 
    -d '{"jsonrpc":"2.0","method":"host.get","params":{"output":["host"]},"id":1}' 
    http://localhost/zabbix/api_jsonrpc.php
{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params.","data":"Not authorized."},"id":1}

Apache doesn’t pass Authorization to FastCGI backends unless you ask it to. One directive fixes it. Put it in its own conf file so a Zabbix package upgrade doesn’t overwrite it:

cat /etc/apache2/conf-available/zabbix-api-auth.conf
<Directory "/usr/share/zabbix/ui">
    CGIPassAuth On
</Directory>

sudo a2enconf zabbix-api-auth
Enabling conf zabbix-api-auth.
To activate the new configuration, you need to run:
  systemctl reload apache2
sudo systemctl reload apache2

curl -s -H 'Content-Type: application/json-rpc' -H "Authorization: Bearer $TOKEN" 
    -d '{"jsonrpc":"2.0","method":"host.get","params":{"output":["host"]},"id":1}' 
    http://localhost/zabbix/api_jsonrpc.php
{"jsonrpc":"2.0","result":[{"hostid":"10084","host":"Zabbix server"}],"id":1}

Worth doing even if you never script anything yourself, because plenty of integrations (Grafana’s Zabbix plugin, Ansible’s Zabbix modules) use token auth and will hit the same wall.

One last habit: when a script is done, log the session out so it doesn’t hang around. After that, the old token is useless:

curl -s -H 'Content-Type: application/json-rpc' -H "Authorization: Bearer $TOKEN" -d '{"jsonrpc":"2.0","method":"user.logout","params":[],"id":1}' http://localhost/zabbix/api_jsonrpc.php
{"jsonrpc":"2.0","result":true,"id":1}

curl -s -H 'Content-Type: application/json-rpc' -H "Authorization: Bearer $TOKEN" -d '{"jsonrpc":"2.0","method":"host.get","params":{"output":["host"]},"id":1}' http://localhost/zabbix/api_jsonrpc.php
{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params.","data":"Session terminated, re-login, please."},"id":1}

Troubleshooting Zabbix agent connection errors

Every one of these came up while building this guide. Match the exact error to the fix.

“Connection reset by peer” from zabbix_get

The TCP connection got through, then the agent hung up. Either the server’s IP isn’t in Server= (the agent log says connection from "x.x.x.x" rejected, allowed hosts: ...), or the agent requires PSK and you connected without it (cannot accept unencrypted connection). Read the agent log; it always says which one.

“cannot connect … connection error (POLLERR,POLLHUP)”

The connection never reached the agent. Firewall on the client (firewalld or UFW), agent not running, or a network ACL or security group in between. Check ss -tlnp | grep 10050 on the client, then the firewall. The layer-by-layer network troubleshooting guide is a good checklist when it’s something further out.

“host [name] not found” in the agent log

The agent reached the server on 10051, but no host with that exact name exists. Either the host hasn’t been created yet, or Hostname= and the frontend host name differ, including case. zabbix_get -k agent.hostname from the server shows what the agent thinks its name is.

ZBX badge is red but zabbix_get works

The client is fine, so look at the host in the UI: wrong IP or port on the agent interface, or an encryption setting that doesn’t match the agent. Hover over the red badge and Zabbix shows the last error.

“ssl/tls alert handshake failure” in the agent log

The agent wants PSK, the server isn’t offering it (or is offering a different identity or key). Re-check the host’s Encryption tab against psk.conf.

Setup confirmation

Here’s the end state, verified from every angle.

Agent running and enabled on both clients:

# ubuntu-client (192.168.100.66)
systemctl is-active zabbix-agent2; systemctl is-enabled zabbix-agent2
active
enabled

# app1, RHEL 9 (192.168.100.65)
systemctl is-active zabbix-agent2; systemctl is-enabled zabbix-agent2
active
enabled
sudo ss -tlnp | grep 10050
LISTEN *:10050 users:(("zabbix_agent2",pid=109076,fd=8))

The server pulling live values from both, plain on app1 and PSK-encrypted on ubuntu-client:

# on the Zabbix server
zabbix_get -s 192.168.100.65 -k system.uptime
22463
zabbix_get -s 192.168.100.65 -k 'proc.num[zabbix_agent2]'
2
zabbix_get -s 192.168.100.66 -k agent.ping --tls-connect psk --tls-psk-identity PSK-ubuntu-client --tls-psk-file /tmp/ubuntu-client.psk
1

The API confirms all three hosts are available for both passive (available) and active (active_available) checks:

curl -s -H "Content-Type: application/json-rpc" -H "Authorization: Bearer $TOKEN" 
    -d '{"jsonrpc":"2.0","method":"host.get","params":{"output":["host","active_available"],"selectInterfaces":["ip","available"]},"id":1}' 
    http://localhost/zabbix/api_jsonrpc.php
{"jsonrpc":"2.0","result":[
  {"hostid":"10084","host":"Zabbix server","active_available":"1","interfaces":[{"ip":"127.0.0.1","available":"1"}]},
  {"hostid":"10780","host":"ubuntu-client","active_available":"1","interfaces":[{"ip":"192.168.100.66","available":"1"}]},
  {"hostid":"10781","host":"app1","active_available":"1","interfaces":[{"ip":"192.168.100.65","available":"1"}]}],"id":1}

In the frontend, Data collection > Hosts shows both new hosts with a green ZBX badge, 82 items each from the Linux template, and ubuntu-client marked PSK under Agent encryption:

Zabbix Hosts list: app1 and ubuntu-client with green ZBX availability, ubuntu-client using PSK agent encryption

Monitoring > Latest data has real numbers flowing in for both clients, checked seconds ago:

Zabbix Latest data showing CPU, memory and disk utilization for ubuntu-client and app1

And the Global view dashboard sums it up: 3 hosts available, 0 unavailable, both clients in the top CPU list, 0 problems:

Zabbix dashboard with 3 hosts available: app1, ubuntu-client and Zabbix server, Zabbix server is running Yes

Frequently asked questions

Which port does the Zabbix agent use?

The agent listens on TCP 10050 for passive checks, where the server connects to it. For active checks and autoregistration the agent connects out to the server on TCP 10051. Open 10050 inbound on clients and 10051 inbound on the server. If you only use active checks, the client needs no inbound port at all.

What’s the difference between passive and active checks?

Passive: the server asks, the agent answers, one request per item. Active: the agent downloads its list of items from the server, collects them on its own schedule, and pushes results in batches. Active scales better and works when the server can’t reach the client. Passive is simpler to debug because you can test any item with zabbix_get. Most people run both, which is what the configs in this guide do.

Can I install the Zabbix agent without adding the Zabbix repository?

Yes, Ubuntu’s universe repo and EPEL both carry Zabbix agents. They tend to lag behind (EPEL offered 6.0 here) and may not match your server version. Using the official repo keeps agent and server in step and makes upgrades predictable.

Does the Zabbix agent need root?

No. It runs as the unprivileged zabbix user by default, and the built-in Linux template doesn’t need more. Some custom checks (reading protected logs, certain hardware sensors) need extra permissions, and the right answer there is targeted sudo rules or group membership, not running the agent as root.

How do I monitor a server that’s behind NAT or in the cloud?

Use active checks only. Set ServerActive to the server’s public address, comment out Server= so the agent doesn’t listen at all, and use the Linux by Zabbix agent active template. The client only makes outbound connections to port 10051, so nothing needs to be opened on its side. Add PSK, since that traffic is crossing networks you don’t control.

How is this different from Prometheus node_exporter?

node_exporter just exposes metrics over HTTP and Prometheus scrapes them; alerting, dashboards and storage are separate pieces. The Zabbix agent is part of one integrated system: templates decide what to collect, the server stores it, evaluates triggers and alerts, and the frontend shows it. Plenty of shops run both. If you’re just after quick per-machine numbers without a central server, the Linux system monitoring commands are still the fastest way to see what a box is doing right now.

Asif Khan

Asif Khan

DevOps, Linux, and cloud engineer with over a decade of hands-on experience. I build infrastructure for uptime and automate operations so problems get handled before anyone gets paged. My focus is automation, security, and systems built to survive failure, using Infrastructure as Code, CI/CD, containers, monitoring, and cloud platforms instead of manual fixes. This blog is where I write down what worked, and just as often what didn't the first time around. Real tutorials you can run yourself, troubleshooting notes pulled from actual outages, and the kind of detail you only get once you've hit the problem firsthand. If you're trying to get Linux, DevOps, and cloud infrastructure to behave, that's what you'll find here: reproducible solutions you can understand, test, and apply in your own environment.