curl vs wget: Differences and When to Use Each

When a script needs to fetch a URL, both curl and wget may appear to do the same job. Their defaults and strengths are different, however. wget is designed around downloading files and recursively retrieving web content, while curl transfers data to or from a URL and gives you detailed control over requests.
This comparison explains the differences between curl and wget, then shows which command fits common download, scripting, and API tasks.
The Short Answer
Use wget when you want to save files, retrieve URLs from a list, mirror web content, or leave a download running in the background. Use curl when you need to send request data, set headers, upload content, work with an API, or pipe a response into another command.
The most visible difference is the default output. wget saves the response to a file, while curl writes it to standard output.
Key Differences
| Property | wget | curl |
|---|---|---|
| Primary purpose | Downloading files and mirroring sites | Transferring data to and from a server |
| Default behavior | Saves to a file | Prints to standard output |
| Recursive download | Yes, built in (-r) | No |
| Follows redirects | Yes, by default | Off by default. Use -L |
| Resume a download | -c | -C - |
| HTTP 404 | Exits with status 8 and creates no output file | Exits with status 0 and prints the response body by default. Add -f for a nonzero exit status |
| Retries | Up to 20 tries by default | Only with --retry |
| Protocols | HTTP, HTTPS, FTP, and FTPS (HTTP and HTTPS only in Wget2, the Fedora default) | Many, including HTTP, FTP, SFTP, SCP, SMTP, and more |
| HTTP/2 | Wget2 only | Yes, when built with HTTP/2 support |
| Background download | Yes (-b) | No |
| Request and upload controls | Supports headers, methods, and request bodies | Extensive controls for headers, authentication, uploads, and request data |
| Reusable library | Standalone program (Wget2 is built on libwget) | Uses libcurl, which applications can use directly |
Downloading a Single File
Both tools handle a single file well, but their defaults differ. wget saves the file using the last component of the URL:
wget https://ftp.gnu.org/gnu/hello/hello-2.12.2.tar.gzThe file is saved in the current directory as hello-2.12.2.tar.gz, with download progress shown in the terminal. A plain curl URL writes the response body to standard output. To save the file using the name from the URL, add -O:
curl -O https://ftp.gnu.org/gnu/hello/hello-2.12.2.tar.gzTo choose the local filename, wget uses -O name and curl uses -o name. With curl, lowercase -o takes a filename, while uppercase -O derives the filename from the URL.
To print the response to standard output with wget, the way curl does by default, use -O -. Adding -q hides the progress messages:
wget -qO- https://example.com/Here, - stands for standard output, so you can pipe the page into another command.
Following Redirects
Download URLs often redirect to a mirror or versioned path. wget follows HTTP redirects by default. With curl, add -L (--location) to follow the Location header. This GitHub URL redirects to the archive download:
curl -L -O https://github.com/curl/curl/archive/refs/tags/curl-8_16_0.tar.gzWithout -L, curl returns the redirect response instead of requesting the final URL. This can leave you with an empty or unexpectedly small file when you expected the actual download.
Resuming an Interrupted Download
Both tools can continue a partial download when the server supports range requests. Run the command from the directory containing the incomplete file. With wget, add -c:
wget -c https://ftp.gnu.org/gnu/hello/hello-2.12.2.tar.gzWith curl, use -C -. The dash tells curl to determine the resume offset from the existing local file:
curl -C - -O https://ftp.gnu.org/gnu/hello/hello-2.12.2.tar.gzHandling Errors in Scripts
The two tools also handle server errors differently. When the server responds with 404 Not Found, wget prints the error, does not create the file, and exits with status 8:
wget https://ftp.gnu.org/gnu/hello/hello-0.0.0.tar.gz--2026-11-29 23:30:54-- https://ftp.gnu.org/gnu/hello/hello-0.0.0.tar.gz
Resolving ftp.gnu.org (ftp.gnu.org)... 209.51.188.20
Connecting to ftp.gnu.org (ftp.gnu.org)|209.51.188.20|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2026-11-29 23:30:54 ERROR 404: Not Found.The ERROR 404: Not Found. line reports the status. Wget creates no new file for this response.
With its default error handling, curl considers a fully received 404 response a successful transfer. The same request with curl -O saves the server’s error page as hello-0.0.0.tar.gz and exits with status 0. The next command in your script then works on an HTML page with a .tar.gz name.
To make curl fail on HTTP errors, add the -f option. In scripts, you will usually see it combined with -s, -S, and -L:
curl -fsSLO https://ftp.gnu.org/gnu/hello/hello-0.0.0.tar.gzcurl: (22) The requested URL returned error: 404The (22) in the message is the exit status curl returns for HTTP errors. The options in this command are:
-f(--fail) - Suppress the response body and exit with status 22 for most HTTP responses with a status of 400 or higher.-s(--silent) - Hide the progress meter.-S(--show-error) - Print the error message even when-sis set.-L(--location) - Follow redirects.-O(--remote-name) - Use the filename from the URL when saving the response.
The non-zero exit status lets you stop the script on a failed download with curl -fsSLO URL || exit 1. For more on how scripts use these values, see our guide on Bash exit codes
.
GNU Wget makes up to 20 total attempts by default for retryable failures. It gives up immediately on errors such as 404 Not Found or a refused connection. Curl retries only when you enable retries. This test URL returns 503 Service Unavailable on every request:
curl --retry 3 --retry-delay 1 https://httpbingo.org/status/503The command makes up to three additional attempts, with a one-second delay between attempts. Add -f when you also want a final HTTP error to produce a nonzero exit status.
By default, --retry covers timeouts, FTP 4xx replies, and HTTP 408, 429, 500, 502, 503, and 504 responses. Curl 8.17.0 added HTTP 522 and 524 to that list. To retry other transfer errors as well, combine --retry with --retry-all-errors.
Downloading Recursively
Recursive retrieval is one of wget’s main advantages. It can inspect downloaded HTML pages, follow links, and retrieve additional content. Curl transfers the URLs you provide but does not crawl pages to discover more URLs.
This example reads the GNU Hello directory listing and follows the link to one archive:
wget -r -np -l 1 -A hello-2.12.2.tar.gz https://ftp.gnu.org/gnu/hello/The -r flag enables recursion, -np (--no-parent) keeps wget below the starting directory, and -l 1 limits it to one level of links. The -A option selects the archive by filename. On a large site, these limits help keep a recursive download to the files you need.
Curl can still download several known URLs in one invocation, including in parallel with --parallel, but it cannot discover those URLs by parsing a page.
Working with an API
For web APIs, curl provides clearer controls for request bodies, headers, authentication, response output, and uploads. This command sends a JSON body to an endpoint that echoes the request:
curl -H "Content-Type: application/json" \
-d '{"name":"linuxize"}' \
https://httpbingo.org/postThe -d option supplies request data and makes curl send a POST request. The response includes a json field with the data you sent. Curl writes the response to standard output, where you can pipe it into a tool such as jq
.
On curl 7.82 and newer, the --json option is a shorter way to send the same request. It sets the Content-Type and Accept headers to application/json and sends the data as a POST body:
curl --json '{"name":"linuxize"}' https://httpbingo.org/postGNU Wget also supports custom methods, headers, and request bodies. It does not support the same range of protocols and upload formats, including multipart/form-data, so curl is generally the better API client. Our guide on using curl with REST APIs
covers request methods, authentication, and response handling in more detail.
Downloading in the Background
For a long download that should continue after the command returns to the shell, wget provides built-in background mode:
wget -b https://ftp.gnu.org/gnu/hello/hello-2.12.2.tar.gzWget writes progress to wget-log unless you select another log file. Curl has no equivalent option built into the command; use shell job control, nohup
, screen, or tmux when a curl transfer must run independently.
The wcurl Wrapper
If you like wget’s download defaults but have only curl, check for wcurl. It is a small wrapper script included in the curl package on Debian 13 and on Ubuntu 24.10 and newer.
To download a file with wcurl, pass the URL:
wcurl https://ftp.gnu.org/gnu/hello/hello-2.12.2.tar.gzTo see which curl options wcurl uses, add --dry-run. It prints one argument per line. Here is the output on Ubuntu 26.04:
wcurl --dry-run https://ftp.gnu.org/gnu/hello/hello-2.12.2.tar.gzcurl
--fail
--globoff
--location
--proto-default
https
--remote-time
--retry
5
--no-clobber
--output
hello-2.12.2.tar.gz
https://ftp.gnu.org/gnu/hello/hello-2.12.2.tar.gzThe --fail and --location options make wcurl fail on HTTP errors and follow redirects, as wget does. --retry 5 retries transient errors up to five times. With --no-clobber, wcurl keeps an existing file and saves the new download under a numbered name.
Availability
Before you pick one for a script, check which tool the target system has. Ubuntu Server installs both. Debian marks wget as a standard package and curl as optional, so a default install with the standard system utilities has wget but not curl. Rocky Linux and other RHEL-based minimal installs include curl but not wget. macOS ships only curl.
When a script has to run on any of these systems, it can use command -v to check for curl first and then for wget:
url=https://ftp.gnu.org/gnu/hello/hello-2.12.2.tar.gz
file=hello-2.12.2.tar.gz
tmpdir=$(mktemp -d ./.download.XXXXXX) || exit 1
tmp=$tmpdir/$file
trap 'rm -f "$tmp"; rmdir "$tmpdir"' EXIT
trap 'exit 1' HUP INT TERM
if command -v curl >/dev/null 2>&1; then
curl -fsSL -o "$tmp" "$url" || exit 1
elif command -v wget >/dev/null 2>&1; then
wget -O "$tmp" "$url" || exit 1
else
printf '%s\n' 'Install curl or wget.' >&2
exit 1
fi
mv -f "$tmp" .Both commands download to a temporary file. A successful download replaces the destination. If the transfer fails, the script removes the temporary file and preserves any existing archive.
Conclusion
Choose wget for file-oriented downloads, recursive retrieval, and built-in background operation. Choose curl for APIs, uploads, pipelines, and detailed request control; the curl command examples and wget command examples guides cover each tool in depth.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 1000+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page