Skip to content
Latchkey

mtr: Usage, Options & Common CI Errors

mtr traces the network path to a host and shows per-hop loss and latency.

mtr merges traceroute and ping into a live per-hop view. In CI you must use report mode (-r) so it runs a fixed number of cycles and exits instead of running interactively forever.

What it does

mtr sends probes along the route to a host and continuously reports, per hop, the packet loss and latency. Report mode emits a static table after a set number of probe cycles, suitable for logging in CI.

Common usage

Terminal
mtr -r -c 10 example.com                       # report mode, 10 cycles
mtr -rw -c 20 example.com                       # wide report (full hostnames)
mtr -r -c 10 -T -P 443 example.com              # TCP probes to port 443
mtr -r -n -c 5 example.com                      # numeric (no DNS)
mtr --json -c 10 example.com

Options

FlagWhat it does
-r / --reportRun cycles then print a report and exit
-c <N>Number of probe cycles (with -r)
-w / --report-wideDo not truncate hostnames
-T -P <port>Use TCP SYN probes to a port
-nSkip DNS resolution of hops
--json / --csvMachine-readable output

Common errors in CI

Without -r, mtr runs interactively and never exits, hanging the job - always use -r (report) with -c. "mtr: unable to get raw sockets: Operation not permitted" means it lacks CAP_NET_RAW (common in unprivileged containers) - run with the capability or use -T/--tcp which can use connect() probes. Many cloud networks rate-limit or drop ICMP, so middle hops show "???" or 100% loss while the final hop is fine - that is normal, not necessarily a fault.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →