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


6 Answers 6


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>"


  • 1
    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, 2019 at 8:38
  • The documentation specifies it works since snapd 2.28. Use snap version to check your current version. Dec 17, 2019 at 13:13
  • Works on Ubuntu 18.04, with snap 2.43.3.
    – Indika K
    Feb 19, 2020 at 10:48
  • this answer really should be marked as ANSWER, works with Ubuntu1804 and snap 2.37.4+18.04.1, jsut a small reminder that if your password has special character, it should be encode (eg: ! = %21)
    – Luke
    Mar 19, 2020 at 7:35
  • For me this worked only without quotation marks (on Ubuntu 20.04)
    – SilverJan
    Nov 18, 2020 at 6:02

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 May 26, 2016 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, 2016 at 13:57
  • 1
    Well what if one wants to automate this configuration?
    – pmatulis
    Dec 19, 2016 at 16:18
  • 2
    Remember, you will need to restart the snapd service before these changes take effect.
    – Seth
    Jan 11, 2017 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, 2019 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.

  • But remember if you add the proxy variables to the /etc/environment file, every other application will have this as their default environment as well Aug 6, 2021 at 7:26

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, 2019 at 12:35
  • This is not ubuntu config.
    – skonsoft
    Jan 17, 2020 at 12:51

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:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .