MacPorts Behind a Slow Proxy

How to set up and use MacPorts behind a proxy, and what to do if your proxy can't serve more than MacPorts' minimum of 1024 bytes/sec. A straightforward but thorough installation guide for old Apple computers.

Published July 10th, 2025  

MacPorts Behind a Slow Proxy

I recently had the misfortune of working on a very old machine (2015 macOS Monterey) that operated behind a proxy, didn’t have Brew support, and needed gcc13 with openMPI support. In another world, I would’ve been “done for,” as I’d have to build ~20 packages from source (and I ran into an issue with configuring one of the dependencies that basically didn’t let me set up openMPI… which I really needed).

Luckily, MacPorts exists.

It has a pretty easy-to-use installer, so download and install MacPorts if you haven’t already.

Once it’s installed, if you restart your terminal, you should be able to run port and have some sort of output show up. If running that gives you an error like “Command port not found,” you probably need to edit your PATH environment variable by putting export PATH="/opt/local/bin:$PATH" in your ~/.bashrc, ~/.bash_profile, or ~/.zshrc (whatever you use).

Now you have MacPorts! If you’re not behind a proxy, everything should work: just run sudo port -d sync (to get the list of ports) and you’ll be ready to run sudo port install (portname) to install ports!

However, if you’re behind a proxy, this is where the fun stuff begins. First, you’ll need to tell MacPorts to use the proxy you’re behind (hopefully you know the address of your proxy — if you don’t… you’ll have to figure out how to access your proxy before continuing). To set your proxy configuration, just run

sudo nano /opt/local/etc/macports/macports.conf

You’ll need to set proxy_http, proxy_https, and proxy_ftp to your proxy, like so:

proxy_http    http://yourproxy.com:port/
proxy_https   https://yourhttpsorhttpproxy.co.uk.gov:port/
ftp_proxy     ftp://yourftpproxy.com:port

We’re not done! MacPorts uses the rsync protocol (instead of HTTP) by default, which is problematic for everyone who doesn’t have an rsync proxy… but if you have an rsync proxy, just add it in the step above and you should be good to go.

If you need to use an HTTP proxy, we just have to change where MacPorts updates from! To do that, edit your sources.conf file:

sudo nano /opt/local/etc/macports/sources.conf

Comment out this line

rsync://rsync.macports.org/release/tarballs/ports.tar [default]

and replace it with HTTP (you can use any other HTTP MacPorts server; this is just the one I used at the time of writing):

http://www.macports.org/files/ports.tar.gz [default]

At this point, everything should work. Try running sudo port -d sync (optionally with -v for verbosity but I don’t think it does much).

Except… sometimes it doesn’t. If your proxy is slow (like mine was), you might get an error like this:

Fetching http://www.macports.org/files/ports.tar.gz failed: Operation too slow. Less than 1024 bytes/sec transferred the last 60 seconds.

I have no idea how to fix it, but it’s easy to work around. We’ll use our browser’s much more permissive networking to get the file, then have MacPorts build the index from that local file. Let’s get started.

Start by visiting the URL (the HTTP MacPorts one above) in a browser to get the file yourself. Then, copy that file into /opt/local/var/macports/sources/www.macports.org/files, delete the existing ports/ directory, and extract the tar file to ./ports. If you use Finder (e.g. you double-click the tarball), it’ll extract to /Downloads, so make sure to copy it back into the right directory. When you’re done, you should have the following directory structure:

/opt/local/var/macports/sources/www.macports.org/files/
    /ports.tar.gz
    /ports/
       /folderA/
       /folderB/
       /aBunchOfFoldersHere/
       /xfce/

Almost done! Run cd ports, then sudo portindex. Portindex will create an index of ports in the current working directory. If it runs successfully, you should see two new files creates: PortIndex and PortIndex.quick. Your output should end with something like:

Successfully indexed XXXX ports.
Failed Ports:        0
Updated Ports:       0

And now you should be done. Run sudo port install (portname) (e.g. sudo port install openmpi-gcc13) and check if it works. Visit https://ports.macports.org to find Ports and, like, have fun!

Sometimes, after installing, you’ll have to alias things yourself (for example, if you already have GCC installed, you’ll need to alias GCC to the newly installed version).

Note: using sudo apparently “sanitizes” the shell and clears some environment variables — often including the proxy ones. To fix that, run:

sudo visudo

And append (to the end of the file)

Defaults        env_keep += "http_proxy HTTP_PROXY ftp_Proxy FTP_PROXY rsync_proxy RSYNC_PROXY"

Credit to Sameer Khan for writing an incredibly helpful blog post.

Liked this article?

More articles