Specify And Change MacPorts Mirror

 ·  · 

Tutorial about how to change MacPorts mirror.

A MacPorts mirror usually has four important parts: portfiles, archives, MacPorts source and distfiles.

1. Portfiles

Portfiles are normally retrieved with port sync or port selfupdate. You can configure Portfiles URL in:


If you installed MacPorts by official dmg package file, the default prefix is /opt/local. So the path of sources.conf is:


Add the Portfiles URL of mirror to sources.conf file.

$ sudo vim /opt/local/etc/macports/sources.conf

Comment all existing rsync URLs and add your mirror URL as default.


# for example
# rsync://mymirror.com/macports/ports/ [default]

2. Archives

Archives contain pre-built installations of ports. In other words archives are repository of binary packages of ports.

You can set archives URL of mirror in


Add archives URL of your mirror to archive_sites.conf file.

$ sudo vim /opt/local/etc/macports/archive_sites.conf

Give a name to your mirror and set the mirror URL.

name my_archives_whatever_name
urls http://mymirror.com/macports/packages/

Additionally, you can use your custom archives only and disable all default archives:

# Following line will disable all default archives 
name macports_archives 

# Following two lines add a custom archives url
name my_archives_whatever_name
urls http://mymirror.com/macports/packages/

3. MacPorts Source

MacPorts is updated during port selfupdate by checking the version on the rsync server. You can specify MacPorts source URL in macports.conf:


There are two parts in a rsync server mirror: rsync_server and rsync_dir.

rsync_server        YOUR_MIRROR_URL
rsync_dir           YOUR_MIRROR_BASE_DIR

# for example
# rsync_server      mymirror.com
# rsync_dir         macports/base/

4. Distfiles

Distfiles means “distribution files”, which contain the source code for ports. They are usually retrieved from the project's own site or one of their mirrors.

If you use the option -s to install a port like below:

$ sudo port install -v -s some_port

MacPorts will fetch source code instead of binary package to build and install the port.

5. Add Proxy

If you want MacPorts to use proxy, you can add proxy settings in macports.conf file.

# /opt/local/etc/macports/macports.conf
# ...

proxy_override_env yes 

# ...

If you are using socks proxy, you have to convert the socks proxy to http proxy first. There is a tutorial about converting socks proxy to http proxy using Polipo.