How to change or configure OpenBSD package install mirror

openbsd commandI am trying to install nginx server on OpenBSD but keep getting an error that read as follows when I run the pkg_add command:

https://mirror.leaseweb.com/pub/OpenBSD/6.1/packages/amd64/quirks-2.304.tgz” title=”quirks-2.304.tgz: ftp: Error retrieving file: 404 Not Found
signify: gzheader truncated
https://mirror.leaseweb.com/pub/OpenBSD/6.1/packages/amd64/nginx-1.10.2p2.tgz” title=”nginx-1.10.2p2.tgz: ftp: Error retrieving file: 404 Not Found
signify: gzheader truncated

How do I change or configure OpenBSD package install mirror for the pkg_add command?


To install or update software packages you need to use the pkg_add command on OpenBSD Unix system. You can PKG_PATH variable pointing to the OpenBSD mirror or edit the file named installurl.

Method 1: Edit /etc/installurl

This file contains a single line specifying an OpenBSD mirror. This file is created by the installer script during installation or upgrade. To edit,
$ doas vi /etc/installurl
Delete or comment out (add # at the beginning of old mirror) existing line. Next add/append a new mirror name
#https://mirror.leaseweb.com/pub/OpenBSD
https://ftp.openbsd.org/pub/OpenBSD

Save and close the file. You can now use the pkg_add command:
$ doas pkg_add -v nginx
To update all installed packages from new mirror run:
$ doas pkg_add -u -v
Sample outputs:

Update candidates: quirks-2.304 -> quirks-2.304
quirks-2.304 signed on 2017-04-02T15:01:33Z
Update candidates: bash-4.4.12 -> bash-4.4.12
Update candidates: gettext-0.19.8.1 -> gettext-0.19.8.1
Update candidates: libiconv-1.14p3 -> libiconv-1.14p3
Update candidates: pcre-8.38p0 -> pcre-8.38p0
Update candidates: pftop-0.7p15 -> pftop-0.7p15

Method 2: Set PKG_PATH shell variable

If a given package name cannot be found, the directories named by PKG_PATH are searched. One can set it as follows for bash/sh/ksh:
# export PKG_PATH=http://ftp.eu.openbsd.org/pub/OpenBSD/`uname -r`/packages/`uname -m`/
OR
# export PKG_PATH=https://ftp4.usa.openbsd.org/pub/OpenBSD/$(uname -r)/packages/$(uname -m)/
Run the command:
# pkg_add -v packagename
# pkg_add -v nginx

Sample outputs:

Update candidates: quirks-2.304 -> quirks-2.304
quirks-2.304 signed on 2017-04-02T15:01:33Z
nginx-1.10.2p2:pcre-8.38p0: ok
nginx-1.10.2p2: ok
The following new rcscripts were installed: /etc/rc.d/nginx
See rcctl(8) for details.
Look in /usr/local/share/doc/pkg-readmes for extra documentation.
Extracted 4819702 from 4820755

For more info see the pkg_add man page:
$ man pkg_add
$ man 5 installurl


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum