How to install wget in macOS?
Categories:
Installing Wget on macOS: A Comprehensive Guide

Learn how to install Wget on macOS using Homebrew, addressing common issues like SSL certificate errors and ensuring a smooth setup for this essential command-line utility.
Wget is a free utility for non-interactive download of files from the web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies. While not pre-installed on macOS, it's an indispensable tool for many developers and system administrators. This guide will walk you through the process of installing Wget on your macOS system, focusing on the most common and recommended method using Homebrew, and addressing potential issues like SSL certificate errors.
Prerequisites: Homebrew Installation
The easiest and most recommended way to install Wget on macOS is by using Homebrew, the missing package manager for macOS. If you don't have Homebrew installed yet, you'll need to install it first. Homebrew simplifies the installation of command-line tools and other software on macOS.
1. Install Homebrew
Open your Terminal application (found in Applications/Utilities) and paste the following command. Press Enter and follow the on-screen instructions. This command will download and execute the Homebrew installation script.
2. Verify Homebrew Installation
After the installation completes, run the following command to ensure Homebrew is correctly installed and configured. It should report 'Your system is ready to brew.'
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Command to install Homebrew
brew doctor
Verify Homebrew installation
Installing Wget via Homebrew
Once Homebrew is set up, installing Wget is a straightforward process. Homebrew handles all dependencies and ensures Wget is correctly linked into your system's PATH.
1. Install Wget
In your Terminal, execute the following command to install Wget. Homebrew will download the latest stable version and its dependencies.
2. Verify Wget Installation
After the installation, you can verify that Wget is correctly installed and accessible by checking its version. This confirms that the executable is in your system's PATH.
brew install wget
Command to install Wget using Homebrew
wget --version
Verify Wget installation and check its version
wget, it will also install necessary libraries like OpenSSL if they are not already present or up-to-date.Addressing SSL Certificate Issues (libressl vs. openssl)
On older macOS versions, or if you've previously installed Wget without Homebrew, you might encounter SSL certificate errors when trying to download files from HTTPS sites. This often stems from Wget being compiled against an outdated or incompatible SSL library (like LibreSSL, which macOS used to ship, instead of OpenSSL). Homebrew typically resolves this by compiling Wget against its own managed OpenSSL version.

Wget SSL Dependency Resolution on macOS
If you experience issues like ERROR: cannot verify <hostname>'s certificate or certificate verification failed, it's likely due to Wget not finding or trusting the correct SSL certificates. Homebrew's installation of Wget usually links against Homebrew's OpenSSL, which includes up-to-date certificate authorities.
wget --no-check-certificate in production environments or when downloading sensitive data, as it bypasses critical security checks and makes you vulnerable to man-in-the-middle attacks. Always aim to resolve the underlying certificate issue.Troubleshooting and Common Commands
Even with Homebrew, sometimes issues can arise. Here are some common troubleshooting steps and useful Wget commands.
1. Update Homebrew and Wget
Ensure your Homebrew installation and all packages are up-to-date. This can often resolve issues caused by outdated software.
2. Reinstall Wget
If you suspect a corrupted installation or persistent issues, you can force Homebrew to reinstall Wget.
3. Check Wget's Dependencies
You can inspect which libraries Wget is linked against to confirm it's using Homebrew's OpenSSL.
brew update && brew upgrade
brew upgrade wget
Update Homebrew and Wget
brew reinstall wget
Reinstall Wget
otool -L $(which wget) | grep ssl
Check Wget's SSL dependencies
The output of otool -L $(which wget) | grep ssl should ideally show a path to Homebrew's OpenSSL, typically something like /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib or similar, depending on your OpenSSL version.