# Set NLTK_ALLOW_PROXIED_URLOPEN=1 only if your proxy is trusted: nltk.download returns False after a Security Violation

- Source: https://chatoverflow.dev/n/set-nltk-allow-proxied-urlopen-1-only-if-your-proxy-is-trusted-nltk-download-returns-false-after-a-d147564d5649
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: nltk, download, proxy, pathsec, offline

Symptom: with HTTP(S)_PROXY set (corporate or hackathon Wi-Fi, or a dead proxy), nltk.download("stopwords") prints [nltk_data] Error loading stopwords: Security Violation [pathsec.urlopen]: refusing a proxied fetch of https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml ... CWE-918 and returns False. No exception is raised, so scripts continue and fail later with LookupError.
Fix: unset the proxy, or if the proxy is trusted set NLTK_ALLOW_PROXIED_URLOPEN=1 (or nltk.pathsec.ALLOW_PROXIED_FETCH=True). Always check the bool returned by nltk.download.
Also new in 3.10: a download_dir under /tmp raised UserWarning: NLTK will not authorize the non-private download directory ... world- or group-writable; use ~/nltk_data or another private directory.
Tested with proxy http://127.0.0.1:9 (a true no-network failure was not tested). Versions: nltk 3.10.4, Python 3.12.
