I know how to configure APT to use a web proxy. But what about snap?


A system option was added in snap 2.28 to specify the proxy server.

$ sudo snap set system proxy.http="http://<proxy_addr>:<proxy_port>"
$ sudo snap set system proxy.https="http://<proxy_addr>:<proxy_port>"


  • 2
    This should probably be the accepted answer. – Mygod Jun 22 '19 at 14:12
  • I am using snap/snapd 2.34.2 on Ubuntu 16.04.5 and these options do not work. Had to go with askubuntu.com/a/1084862/75760 , changing the systemd settings – hanxue Aug 12 '19 at 8:38
  • 1
    This should be the accepted answer – sayem siam Aug 30 '19 at 19:39
  • The documentation specifies it works since snapd 2.28. Use snap version to check your current version. – DependencyHell Dec 17 '19 at 13:13
  • Works on Ubuntu 18.04, with snap 2.43.3. – Indika K Feb 19 '20 at 10:48

snapd reads /etc/environment, so setting the usual proxy environment variables there works. On Ubuntu, that's done automatically for you by Settings → Network → Network proxy, so as long as you restart snapd after changing that file you should be set.

  • 2
    Being more specific, the snapd.service file is located here: /lib/systemd/system/snapd.service – julian-alarcon May 26 '16 at 13:28
  • 1
    @darkhole one shouldn't edit /lib/systemd/system/snapd.service, but use systemctl edit snapd.service. See my answer: askubuntu.com/questions/659267/… – muru Jun 7 '16 at 13:57
  • 1
    Well what if one wants to automate this configuration? – pmatulis Dec 19 '16 at 16:18
  • 2
    Remember, you will need to restart the snapd service before these changes take effect. – Seth Jan 11 '17 at 22:07
  • 3
    The method you posted here also doesn't work with authentication. Snap should just use the normal $http_proxy and $https_proxy env vars like everyone else. Here is the ubuntu bug tracker link for this problem. – Teque5 Jan 31 '19 at 17:31

There is another way to add environment variables to systemd services:

Create a folder for the snap daemon and create configuration files for the environment variables:

$ sudo mkdir -p /etc/systemd/system/snapd.service.d/
$ echo -e '[Service]\nEnvironment="http_proxy="' \
      | sudo tee /etc/systemd/system/snapd.service.d/http-proxy.conf
$ echo -e '[Service]\nEnvironment="https_proxy="' \
      | sudo tee /etc/systemd/system/snapd.service.d/https-proxy.conf
$ sudo systemctl daemon-reload
$ sudo systemctl restart snapd

After that you can check if the environment variables are set for snapd:

$ systemctl show snapd | grep proxy
  Environment=http_proxy= https_proxy=
  DropInPaths=/etc/systemd/system/snapd.service.d/http-proxy.conf /etc/systemd/system/snapd.service.d/https-proxy.conf

Snap uses snapd daemon. You only need to define http_proxy and https_proxy in /etc/environment and restart the service: systemctl restart snapd.


There is a reported bug:


Please subscribe to check changes on it.


Be careful, because the snapd reads the /etc/environment file instead of get the ENV variable. This example below doesn't work:

export https_proxy=http://<your.ip.here>:3128

you have to use:


Snap service is configured to use special environment file, so you can just add http_proxy variable to it if your current environment variables are not picked up by the snap.

Open file:

sudo vim /etc/sysconfig/snapd


  • 1
    There is no sysconfig folder on Ubuntu. – smartmouse Nov 18 '19 at 12:35
  • This is not ubuntu config. – skonsoft Jan 17 '20 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.