# How to change mirror in pkg



## rempas (Apr 21, 2021)

I just installed FreeBSD and the download speeds of pkg(8) or suuuper slow. I'm searching online but I can't find any documentation. Can anyone help me?


----------



## SirDice (Apr 21, 2021)

It's already automatically switched based on GeoDNS. 

http://pkg.freebsd.org/


----------



## rempas (Apr 21, 2021)

Oh ok! Thanks a lot!


----------



## broozar (Apr 21, 2021)

Out of interest, I once read a guide that you could modify /usr/local/etc/pkg/repos/FreeBSD.conf and force a mirror through `url: "pkg+http://pkg.${MIRROR}FreeBSD.org/${ABI}/latest"`, where MIRROR is eu., us-west., us-east., etc.

Is this still valid advice?


----------



## SirDice (Apr 21, 2021)

broozar said:


> Is this still valid advice?


You can try but:

```
IMPORTANT: We do NOT guarantee uptime of any particular mirror. We provide SRV fallbacks for redundancy.
```


----------



## broozar (Apr 21, 2021)

That is exactly my observation. I used eu., which is usually a bit faster than the default, however a couple of days ago, I could not connect to the server at all.
So in summary, pkg should switch automatically based on location and manually forcing a mirror could potentially break things. I will adjust my scripts.


----------



## SirDice (Apr 21, 2021)

Yep, you can force pkg(8) to use a specific mirror but there's no guarantee that specific mirror will be up. If you use pkg.freebsd.org this switching will happen automagically.


----------



## suntzu00 (Apr 21, 2021)

there's a tool for it ports-mgmt/fastest_pkg


----------



## blarf (Sep 16, 2021)

SirDice said:


> Yep, you can force pkg(8) to use a specific mirror but there's no guarantee that specific mirror will be up. If you use pkg.freebsd.org this switching will happen automagically.


Unfortunately I ended up pinning a specific mirror because whatever geo magic happened behind the scenes would consistently route me to a mirror that throttled downloads to 100 KB/s.


----------



## koutheir (Dec 3, 2022)

The solution I found fixes the issue, but I don't know why. I created the file `/usr/local/etc/pkg/repos/FreeBSD.conf` with the following line:
`FreeBSD: { url: "https://pkg.freebsd.org/${ABI}/quarterly" }`


----------



## SirDice (Dec 5, 2022)

koutheir said:


> The solution I found fixes the issue, but I don't know why. I created the file `/usr/local/etc/pkg/repos/FreeBSD.conf` with the following line:
> `FreeBSD: { url: "https://pkg.freebsd.org/${ABI}/quarterly" }`


This is the default on -RELEASE versions.


----------

