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 downloading files from the command line.
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 it's a staple on Linux systems, macOS users often find it's not pre-installed. 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 how to troubleshoot potential issues, especially those related to SSL/TLS.
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, you'll need to install it first. Homebrew simplifies the installation of command-line tools and other software that Apple doesn't include by default.
1. Open Terminal
Launch the Terminal application from your Applications/Utilities folder or by searching for it using Spotlight (Cmd + Space).
2. Install Homebrew
Paste the following command into your Terminal and press Enter. Follow the on-screen prompts, which may include entering your administrator password and installing Xcode Command Line Tools if they are not already present.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Command to install Homebrew
brew doctor
to check for any potential issues with your Homebrew setup and brew update
to ensure your package definitions are up to date.Installing Wget via Homebrew
Once Homebrew is successfully installed, installing Wget is a straightforward process. Homebrew will handle all dependencies, including the necessary SSL libraries.
1. Install Wget
In your Terminal, execute the following command to install Wget:
2. Verify Installation
After the installation completes, you can verify that Wget is correctly installed and accessible by checking its version:
brew install wget
Command to install Wget using Homebrew
wget --version
Command to verify Wget installation
Troubleshooting SSL/TLS Issues (libressl vs. libssl)
Occasionally, users might encounter issues with Wget failing to download HTTPS resources, often manifesting as SSL certificate errors. This can happen if Wget is linked against an older or incompatible SSL library, such as LibreSSL (which macOS ships with) instead of OpenSSL (which Homebrew typically provides). Homebrew usually manages these dependencies correctly, but manual intervention might be needed in specific scenarios, especially on older macOS versions like El Capitan.
flowchart TD A[Start: Wget Installation] --> B{Homebrew Installed?} B -- No --> C[Install Homebrew] B -- Yes --> D[Run 'brew install wget'] D --> E{Wget Works?} E -- Yes --> F[End: Wget Ready] E -- No --> G[Check SSL/TLS Issues] G --> H[Ensure OpenSSL is Linked] H --> I[Reinstall Wget with OpenSSL] I --> E
Wget Installation and Troubleshooting Flow
1. Check OpenSSL Linkage
Verify if OpenSSL is correctly linked by Homebrew. If it's not, you might see warnings or errors.
2. Force Link OpenSSL (if necessary)
If OpenSSL isn't linked or you're experiencing issues, you can try to force link it. Be cautious as this can sometimes cause conflicts if other software relies on a different OpenSSL version.
3. Reinstall Wget with OpenSSL (if issues persist)
If problems persist, you might need to reinstall Wget, ensuring it uses Homebrew's OpenSSL. Homebrew usually handles this automatically, but an explicit reinstall can sometimes resolve linking issues.
brew doctor
brew info openssl
Commands to check Homebrew and OpenSSL status
brew link --force openssl
Command to force link OpenSSL
brew reinstall wget
Command to reinstall Wget
By following these steps, you should have Wget successfully installed and configured on your macOS system, ready to download files from the command line without encountering common SSL/TLS related issues.