wget -U (--user-agent): set or remove the User-Agent header
- tool
- wget
- command
- wget
- flag
- -U, --user-agent=AGENT
- default
- Wget/VERSION
wget -U "release-sync/1.0 (ops@example.com)" URL sends that string as the User-Agent request header instead of wget's default Wget/VERSION. Use it when a server or CDN treats clients differently by agent, when an API asks clients to identify themselves, or to get the same response a browser gets. -U "" (an empty string) removes the header entirely: wget's source only adds a custom agent when the value is non-empty.
Syntax
wget -U "release-sync/1.0 (ops@example.com)" https://example.org/app.tar.gz
wget --user-agent="Mozilla/5.0 (X11; Linux x86_64)" https://example.org/page.html
wget -U "" https://example.org/file.txt # send no User-Agent at all
wget --header="User-Agent: release-sync/1.0" https://example.org/file.txtQuote the value: agent strings usually contain spaces and parentheses, which the shell would otherwise split or interpret. A value with an embedded newline is rejected with an "Invalid value" error, so the option cannot be used to inject extra headers.
Values and their effect
| What you pass | Header wget sends |
|---|---|
| (nothing) | User-Agent: Wget/VERSION |
| -U "Name/1.0" | User-Agent: Name/1.0 |
| -U "" | No User-Agent header |
| --header="User-Agent: Name/1.0" | User-Agent: Name/1.0 (headers from --header replace the generated one) |
| user_agent = Name/1.0 in .wgetrc | User-Agent: Name/1.0 for every run, unless -U overrides it |
Related HTTP options
| Option | Use |
|---|---|
| --header="Name: value" | Add any other request header, such as Accept or Authorization |
| --referer=URL | Set the Referer header, which some download pages check together with the agent |
| -S, --server-response | Print the response headers, to see what the server answered |
| -d, --debug | Print the request headers too, including the User-Agent sent (if wget was built with debug support) |
| -e robots=off | Ignore robots.txt in recursive mode; -U does not change robots handling |
Pitfalls
- 403 is not always about the agent. The ERROR 403: Forbidden page lists the other causes; changing
-Uonly helps when the server documents or clearly applies agent filtering. - Recursive downloads still read robots.txt. wget fetches and obeys it whatever agent string you set; a browser-like
-Udoes not bypass it (only-e robots=offdoes). - Be honest about automation. A descriptive agent with a contact address is what most API terms ask for and is less likely to be rate-limited than a fake browser string.
- curl differs. curl's equivalent is
curl -A "Name/1.0"; its default iscurl/VERSION.
FAQ
What User-Agent does wget send by default?
Wget/ followed by its version, for example Wget/1.25.0. Run wget -S or point it at a local server that echoes headers to see the exact value of your build.
Does -U help when a site answers 403 Forbidden?
Only when the site filters on the agent string. Many 403s come from authentication, geo or rate rules; check the response with -S and the site's terms before changing the agent.
How do I set the User-Agent for every wget run?
Add user_agent = MyTool/1.0 to ~/.wgetrc (or the system wgetrc). The command-line -U still overrides it.