I was downloading from a very intermittent webserver and the download kept quitting less than 80% in. And if my timing wasn’t perfect, the web browser wouldn’t resume it. Then I thought to try to resume my downloads with wget.
wget is a command line tool for Linux, other Unix-like operating systems, and Windows. It is good for resuming downloads and can even do it automatically.
When all goes well, all it takes is this simple command:
wget -c url
Copy the address from your browser and paste it into the command line in place of url.
Run the command from the same directory your download is in, and it resumes, regardless of what you used to start the download. The -c option tells wget to pick up at the end of the matching file in the current directory.
If the server seems to have a habit of dropping, you can make wget automatically resume downloads, which is nice. Here’s the command for that.
wget --tries=0 --timeout=5 -c url
These additional options tell wget to retry indefinitely, and to timeout after five seconds in addition to continuing wherever the file happens to have left off. If you want it to only retry a set number of times and then give up, specify the number in place of 0. You can also specify a longer timeout if five seconds seems to be too impatient.
Resume downloads with wget when the server doesn’t like wget
Some sites don’t like wget. Because, well, hacking tool! If the download finishes immediately and the resulting file is only a few bytes, that’s what’s going on. The server is detecting wget, deciding you’re up to no good, and giving you a message to that effect instead of the file you want. You can type or cat the file from a command line to verify that’s what’s going on.
To get around this, spoof your user agent. Use wget’s -U argument to do that.
wget -U "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0" -c url
Any valid semi-current web browser user agent string will do. You can use a site like https://www.whatismybrowser.com/detect/what-is-my-user-agent to check yours. Then copy and paste that result into your command line, in between the quotes. Or just copy my example above, it will be good for a while.
Just like before, if the server seems to have a habit of dropping, you can add in the other options to make wget automatically resume your download.
wget --tries=0 --timeout=5 -U "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0" -c url
What to do if you get SSL, TLS, or other security errors
I got SSL errors at first, which I traced to using a too-old version of wget. The official GNU wget for Windows is dated and does not support current cryptography standards. Since most of the web uses https these days, that’s a problem. I found a suitable Windows version of wget at eternallybored.org. It’s a standalone version too, which makes it more convenient than the official GNU build, which requires an installer.