/errors/nmap/scan-type-requires-root-privileges
nmap: You requested a scan type which requires root privileges. QUITTING!
The commands on this page have not been executed by our verification runner yet.updated
- tool
- Nmap
- exit code
- 1
- versions
- Nmap 7.x
- os
- linux, macos
Nmap prints You requested a scan type which requires root privileges. followed by QUITTING! when a scan needs to send raw packets and the process may not open raw sockets. SYN scans (-sS), UDP scans (-sU), OS detection (-O) and similar techniques build packets by hand, which ordinary users cannot do. Run the scan with sudo, or use the TCP connect scan (-sT), which uses the normal connect() system call and needs no privileges.
Which scans need privileges
| Option | Scan | Needs root or raw-socket rights |
|---|---|---|
| -sT | TCP connect scan | no |
| -sS | TCP SYN scan (default when privileged) | yes |
| -sU | UDP scan | yes |
| -sA, -sF, -sN, -sX | ACK, FIN, NULL, Xmas scans | yes |
| -O | OS detection | yes |
| -sV | version detection | no (with -sT) |
| -sn | host discovery only | no, but unprivileged discovery uses TCP connects instead of ARP and ICMP |
When you run nmap without a scan type as a normal user, it chooses -sT by itself; the error appears only when a privileged type is requested explicitly.
Fixes
# privileged scan of your own host
sudo nmap -sS -p 1-1024 127.0.0.1
# unprivileged alternative
nmap -sT -p 1-1024 127.0.0.1Linux: capabilities instead of sudo
Nmap can use raw sockets without running as root when its binary has the needed capabilities and you pass --privileged:
sudo setcap cap_net_raw,cap_net_admin,cap_net_bind_service+eip "$(command -v nmap)"
nmap --privileged -sS -p 22,80,443 127.0.0.1Sources
Related pages
commands · nmapnmap -p: scan specific ports, port ranges or all 65535 portsnmap -p 22,80,443 HOST scans only those ports; -p 1-1024 a range, -p- all 65535, -p U:53,T:22 mixes UDP and TCP. --top-ports N and --open narrow the results.commands · ssss -tulpn: list listening ports and the process using themss -tulpn lists listening TCP and UDP ports with the owning process on Linux. What each flag means, filters for one port, and macOS and Windows equivalents.compare · iptablesiptables vs nftables: differences and migrationnftables replaces iptables, ip6tables, arptables and ebtables with one tool, nft, one syntax and atomic updates; iptables-nft keeps iptables commands working.