The error is not from nmap — it is from your shell. 'nmap' is not recognized as an internal or external command, operable program or batch file (Command Prompt) and Command 'nmap' not found (PowerShell, Linux, macOS) both mean the same thing: the shell looked for an executable named nmap, checked every directory in its search path, and found nothing.
So the question is never “is nmap broken” but “why can this shell not see it”. Seven causes, in the order they actually occur.
Triage: which shell says it?
| Where you see the error | What it means | Go to |
|---|---|---|
| Command Prompt or PowerShell, fresh install | PATH missing or stale | Causes 1–2 |
| PowerShell works, Command Prompt does not (or vice versa) | One terminal predates the install | Cause 2 |
| WSL, Git Bash, or a remote SSH session | A different system than the one nmap was installed on | Cause 3 |
| Everywhere, even from the install folder | The install is damaged | Causes 4–5 |
Linux or macOS: command not found: nmap | Not installed on that system | Cause 7 |
1. The Nmap folder is not in PATH
The canonical cause. The Windows installer normally adds C:\Program Files (x86)\Nmap to the system PATH, but the option can be unchecked, the install may have run without admin rights, or a corporate image may strip it afterwards.
where nmap
:: nothing printed = the folder is not in PATH at all
Fix it once: press Win+R, run SystemPropertiesAdvanced.exe, open Environment Variables, edit Path under System variables, add C:\Program Files (x86)\Nmap, and confirm every dialog with OK. Then open a new terminal (cause 2 explains why the old one will not see it).
2. The terminal predates the install
Windows terminals copy the environment when they start. A window opened before the installer finished — including the second tab of Windows Terminal, and the integrated terminal inside VS Code — keeps the old PATH forever. This is why nmap works “sometimes”: new windows find it, old ones do not.
Close every terminal window (all tabs) and open a new one. In PowerShell you can reload the environment without restarting:
$env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine') + ';' +
[System.Environment]::GetEnvironmentVariable('Path','User')
Chocolatey users can run refreshenv instead. Either way, the verification is identical: where nmap in the window you are actually using.
3. Wrong system: WSL, Git Bash, or a remote session
Windows Subsystem for Linux is a separate Linux machine. Installing nmap in Windows does not put it on the WSL PATH, and vice versa. The same applies to remote sessions: nmap must exist on the box where the shell runs.
# inside WSL or any Debian/Ubuntu system
sudo apt update && sudo apt install -y nmap
# on macOS with Homebrew (Apple Silicon: /opt/homebrew/bin)
brew install nmap
Git Bash and MSYS see the Windows PATH, so cause 1–2 apply there; but if you installed nmap for Windows while testing from WSL, the fix is the install above, not a PATH edit.
4. The install is incomplete or damaged
The PATH entry can exist while the executable does not — an interrupted installer, an antivirus quarantine, or an upgrade that removed the old folder before writing the new one. Also check the Npcap component: the installer has a separate step for it, and without Npcap many scan types fail even though nmap launches.
dir "C:\Program Files (x86)\Nmap\nmap.exe"
:: File not found = the install itself is the problem
Repair: re-run the installer as administrator from nmap.org/download, keep the PATH option ticked, and let it install Npcap. Antivirus products occasionally quarantine nmap.exe — check the protection history before assuming the installer failed.
5. PATH corruption: truncation, typos, and impostors
Three quiet killers live in the PATH string itself:
- Truncation. The Windows system-variables dialog silently cuts PATH at roughly 2 047 characters. If your PATH is long, the Nmap entry may have been cut off — inspect
echo %PATH%and look for the tail ending mid-entry. - Bad entries. Quotes around the entry (
"C:\Program Files (x86)\Nmap") and stray trailing backslashes or semicolons break the parser. Entries must be bare paths. - Impostors. A different
nmap.batornmap.exeearlier in PATH shadows the real one — symptoms vary from wrong versions to instant exits.where nmaplists every match in resolution order; the first line is what your shell runs.
6. Permission and policy layer
Editing the system PATH needs administrator rights; without them you may have silently edited the user PATH instead, which is fine — but changes only apply to new processes. On managed machines, group policy can rewrite the PATH at logon and discard local edits. If you cannot change PATH at all, run nmap by full path — nothing about scanning requires the PATH:
& "C:\Program Files (x86)\Nmap\nmap.exe" --version
A shortcut with the full path, or a small wrapper script in a folder you do control, is a permanent workaround until policy allows the real fix.
7. Not installed on this system at all (Linux / macOS)
command not found: nmap on a fresh WSL, Kali minimal install or Mac means exactly that: no nmap here. The packages in cause 3 fix it. On Kali it ships by default — if it is missing there, the image is a minimal variant and sudo apt install nmap is still the answer.
Confirm the fix
| Command | Expected result |
|---|---|
where nmap (or which nmap) | Prints exactly one path — the real install |
nmap --version | Version banner, no shell error |
nmap -sV 127.0.0.1 | A scan runs and reports a port state |
The last one is the real test: it proves the executable, the Npcap driver and the raw-sockets path all work together. If the scan runs but host discovery fails on real targets, that is a different problem — see Nmap Requires Root Privileges.
Frequently asked questions
What does “nmap is not recognized as an internal or external command” mean?
It is a shell error, not an nmap error. The shell searched every directory in PATH for an executable named nmap and found none — either nmap is not installed on this system, or its install folder is not in this shell’s PATH.
How do I add nmap to PATH on Windows 11?
SystemPropertiesAdvanced.exe → Environment Variables → System variables → Path → Edit → New → C:\Program Files (x86)\Nmap. OK out of every dialog, then open a brand-new terminal — existing windows keep the old PATH.
Why does nmap work in Command Prompt but not in WSL?
Because WSL is a separate Linux system with its own PATH and its own installed programs. Windows installs are invisible inside it. Install nmap inside WSL (sudo apt install nmap) or run it from the Windows side.
Is “nmap not found” on Linux or macOS the same problem?
Same diagnosis — the executable is not on the shell’s search path — but the usual cause is simply that nmap was never installed on that system. sudo apt install nmap on Debian-family systems, brew install nmap on macOS.
Do I need to reinstall nmap when it is not recognized?
Usually not. Nine times out of ten it is a PATH or stale-terminal problem and the install is perfectly fine. Run dir "C:\Program Files (x86)\Nmap\nmap.exe" first — if the file exists, skip the reinstall and fix the PATH.
See also: Nmap "Host Seems Down" / "No Route to Host" — six scan errors and their causes.