How to fix iotop 'Netlink error: Operation not permitted (1)'

Problem:

You are trying to run iotop but you see an error message like

Netlink error: Operation not permitted (1)

The Linux kernel interfaces that iotop relies on now require root priviliges
or the NET_ADMIN capability. This change occured because a security issue
(CVE-2011-2494) was found that allows leakage of sensitive data across user
boundaries. If you require the ability to run iotop as a non-root user, please
configure sudo to allow you to run iotop as root.

Please do not file bugs on iotop about this.

Solution

You need to run iotop as root:

sudo iotop

The reason for this is that iotop needs to access kernel interfaces that are only accessible to root users or if the user/process has the CAP_NET_ADMIN capability. In theory you could add this capability using sudo setcap cap_net_admin+ep /usr/sbin/iotop but on Ubuntu 18.04 this did not work for me.