How to fix OpenWRT opkg Failed to send request: Operation not permitted

Problem:

When running opkg update or other opkg commands in OpenWRT, you see these error messages:

Failed to send request: Operation not permitted

Full log example:

Downloading http://downloads.openwrt.org/releases/19.07.5/targets/ath79/generic/packages/Packages.gz
Failed to send request: Operation not permitted
*** Failed to download the package list from http://downloads.openwrt.org/releases/19.07.5/targets/ath79/generic/packages/Packages.gz

Downloading http://downloads.openwrt.org/releases/19.07.5/targets/ath79/generic/kmods/4.14.209-1-b84a5a29b1d5ae1dc33ccf9ba292ca1d/Packages.gz
Failed to send request: Operation not permitted
*** Failed to download the package list from http://downloads.openwrt.org/releases/19.07.5/targets/ath79/generic/kmods/4.14.209-1-b84a5a29b1d5ae1dc33ccf9ba292ca1d/Packages.gz

[...]

Solution:

This problem is typically caused by no DNS servers being set.

First, check if you have internet access using

ping 1.1.1.1

The output should look like this (otherwise, you have no internet access):

root@OpenWrt:~# ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: seq=0 ttl=59 time=36.078 ms
64 bytes from 1.1.1.1: seq=1 ttl=59 time=33.538 ms
64 bytes from 1.1.1.1: seq=2 ttl=59 time=33.350 ms

Now try to ping techoverflow.net:

root@OpenWrt:~# ping techoverflow.net
ping: bad address 'techoverflow.net'

This verifies that you have internet connectivity but no DNS.

Now go into LuCI, go to Network/Interfaces and edit each interface. Set

1.1.1.1

and

1.0.0.1

This might not be possible for some interfaces since they have a different IP address configuraton (in that case, just proceed with the other interfaces). The configuration for the interface should now look like this:

Don’t forget to Save & Apply!

After that, retry opkg update which should now look like this:

root@OpenWrt:~# opkg update
Downloading http://downloads.openwrt.org/releases/19.07.5/targets/ath79/generic/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_core
Downloading http://downloads.openwrt.org/releases/19.07.5/targets/ath79/generic/packages/Packages.sig
Signature check passed.
Downloading http://downloads.openwrt.org/releases/19.07.5/targets/ath79/generic/kmods/4.14.209-1-b84a5a29b1d5ae1dc33ccf9ba292ca1d/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_kmods
Downloading http://downloads.openwrt.org/releases/19.07.5/targets/ath79/generic/kmods/4.14.209-1-b84a5a29b1d5ae1dc33ccf9ba292ca1d/Packages.sig
Signature check passed.
[...]