# disable proxy

**URL:** https://discourse.nixos.org/t/disable-proxy/5295
**Category:** Inbox
**Created:** [January 2, 2020, 5:09pm UTC](https://discourse.nixos.org/t/disable-proxy/5295 "2020-01-02T17:09:21Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![parisni](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/p/898d66/32.png) [@parisni](https://discourse.nixos.org/u/parisni)
#### Post date: [January 2, 2020, 5:09pm UTC](https://discourse.nixos.org/t/disable-proxy/5295/1 "2020-01-02T17:09:21Z")

</div>

hi

i installed my system with a proxy to access network (configured  
networing.proxy.default in the configuration.nix file).  
Right now I am using a network without a proxy. Then I commented the  
networing.proxy.default line and run  
nixos-rebuild switch

however the rebuild tries to access some remote url ... with the previous proxy  
configuration.

how to turn on / off the proxy (manually unset the \*\_proxy env variable is not  
working)?

thanks

---

<div class="post-metadata">

### Author: ![jonringer](https://discourse.nixos.org/user_avatar/discourse.nixos.org/jonringer/32/1348_2.png) [@jonringer](https://discourse.nixos.org/u/jonringer)
#### Post date: [January 2, 2020, 7:15pm UTC](https://discourse.nixos.org/t/disable-proxy/5295/2 "2020-01-02T19:15:23Z")

</div>

nixos-rebuild may not actually restart some services if it impacts your current session. I would try rebooting to see if it fixes your issue.

---

<div class="post-metadata">

### Author: ![zimbatm](https://discourse.nixos.org/user_avatar/discourse.nixos.org/zimbatm/32/4_2.png) [@zimbatm](https://discourse.nixos.org/u/zimbatm)
#### Post date: [January 2, 2020, 8:59pm UTC](https://discourse.nixos.org/t/disable-proxy/5295/3 "2020-01-02T20:59:22Z")

</div>

> <https://github.com/NixOS/nixpkgs/blob/0b5c6267bbc9d9377b9bf7d7596962702d17cf5e/nixos/modules/config/networking.nix#L196-L215>

The module sets environment variables and those are updated after a successful `nixos-rebuild switch`. On top of that the user has to logout and login back again for the new variables to take effect.

If the proxy is enabled but log longer available it can affect the nixos-rebuild because those environment variables are taken into account by nix. To work around that you can `unset http_proxy` and the other proxy variables outputted by `env | grep proxy` in the terminal before running `nixos-rebuild switch`.

---

<div class="post-metadata">

### Author: ![parisni](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/p/898d66/32.png) [@parisni](https://discourse.nixos.org/u/parisni)
#### Post date: [January 3, 2020, 4:50pm UTC](https://discourse.nixos.org/t/disable-proxy/5295/4 "2020-01-03T16:50:24Z")

</div>

> To work around that you can unset http\_proxy and the other proxy variables  
> outputted by env | grep proxy in the terminal before running nixos-rebuild  
> switch.

I tried to unset every result of env|grep proxy. Still nixos-rebuild  
switch returns “couldn’t resolve proxy name”. Thanks for any help on  
this

---

<div class="post-metadata">

### Author: ![zimbatm](https://discourse.nixos.org/user_avatar/discourse.nixos.org/zimbatm/32/4_2.png) [@zimbatm](https://discourse.nixos.org/u/zimbatm)
#### Post date: [January 3, 2020, 9:14pm UTC](https://discourse.nixos.org/t/disable-proxy/5295/5 "2020-01-03T21:14:06Z")

</div>

You’re right, the proxy env vars are actually set on the nix-daemon directly instead of being forwarded by the client:

> <https://github.com/NixOS/nixpkgs/blob/dce9dfaa9809b3e2d3a564b4b590b1e59a9a6103/nixos/modules/services/misc/nix-daemon.nix#L428-L430>

Typically with systemd it’s possible to override existing units but not on NixOS:

```auto
$ sudo systemctl edit nix-daemon
Failed to create temporary file for "/etc/systemd/system/nix-daemon.service.d/override.conf": Read-only file system

```

This is because `/etc/systemd/system` points into the `/nix/store` which is mounted read-only for everyone except the nix-daemon. You also can’t edit the unit itself because of the same reason.

Now I am running a bit out of ideas.

ESCAPE HATCH. DON’T PRESS THE RED BUTTON.

As a last recourse, you can re-mount the /nix/store read-write and edit the unit. This is obviously really bad as the store becomes no longer consistent.

```auto
$ sudo mount -o remount,rw /nix/store
# Look for the file and remove the lines:
$ sudo systemstd cat nix-daemon
$ sudo mount -o remount,ro /nix/store
$ sudo systemctl stop nix-daemon.socket nix-daemon
$ sudo systemctl start nix-daemon

```

Try running the nixos-rebuild. Since the nix-daemon is socket-actived it will only start after nix-build has been invoked. If it doesn’t work you can also check what environment variables the daemon has like that:

```auto
sudo cat /proc/$(pgrep nix-daemon)/environ | tr '\0' '\n'

```

---

<div class="post-metadata">

### Author: ![parisni](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/p/898d66/32.png) [@parisni](https://discourse.nixos.org/u/parisni)
#### Post date: [January 4, 2020, 9:53am UTC](https://discourse.nixos.org/t/disable-proxy/5295/6 "2020-01-04T09:53:35Z")

</div>

Hi Zimatm

thanks for your help. I change proxy configuration several times a day.  
I am not confident such complicated a solution is appropriate in this case.

This may require a fix in the nixos-rebuild strategy isnt’it ? For  
example changing the proxy before trying to access remote url ?

---

<div class="post-metadata">

### Author: ![7c6f434c](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/7/8e7dd6/32.png) [@7c6f434c](https://discourse.nixos.org/u/7c6f434c)
#### Post date: [January 4, 2020, 10:19am UTC](https://discourse.nixos.org/t/disable-proxy/5295/7 "2020-01-04T10:19:50Z")

</div>

> thanks for your help. I change proxy configuration several times a day.  
> I am not confident such complicated a solution is appropriate in this case.

In such a situation I just instlled a local proxy, installed multiple configuration files for it, used the local proxy as the proxy in most programs and restarted the proxy with a proper upstream as needed.

---

<div class="post-metadata">

### Author: ![parisni](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/p/898d66/32.png) [@parisni](https://discourse.nixos.org/u/parisni)
#### Post date: [January 4, 2020, 11:05am UTC](https://discourse.nixos.org/t/disable-proxy/5295/8 "2020-01-04T11:05:15Z")

</div>

> In such a situation I just instlled a local proxy, installed multiple

Thanks for the suggestion. However, how can I install a local proxy, if  
I am unable to install anything (because nixos-rebuild is stuck) ?

---

<div class="post-metadata">

### Author: ![7c6f434c](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/7/8e7dd6/32.png) [@7c6f434c](https://discourse.nixos.org/u/7c6f434c)
#### Post date: [January 4, 2020, 11:38am UTC](https://discourse.nixos.org/t/disable-proxy/5295/9 "2020-01-04T11:38:10Z")

</div>

> > In such a situation I just instlled a local proxy, installed multiple
> 
> Thanks for the suggestion. However, how can I install a local proxy, if  
> I am unable to install anything (because nixos-rebuild is stuck) ?

I think you could run the following as root:

NIX\_REMOTE= http\_proxy= https\_proxy= nix-build ‘\<nixpkgs/nixos\>’ -I ‘nixos-config=/etc/nixos/configuration.nix’ --no-out-link -A system

Afterwards nixos-rebuild will not need to build anything, so lack of network access should be OK.

---

<div class="post-metadata">

### Author: ![parisni](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/p/898d66/32.png) [@parisni](https://discourse.nixos.org/u/parisni)
#### Post date: [January 4, 2020, 11:59am UTC](https://discourse.nixos.org/t/disable-proxy/5295/10 "2020-01-04T11:59:56Z")

</div>

> NIX\_REMOTE= http\_proxy= https\_proxy= nix-build ‘\<nixpkgs/nixos\>’ -I  
> ‘nixos-config=/etc/nixos/configuration.nix’ --no-out-link -A system
> 
> Afterwards nixos-rebuild will not need to build anything, so lack of network  
> access should be OK.

This worked, also I had to add this “all\_proxy=”:

NIX\_REMOTE= http\_proxy= https\_proxy= all\_proxy= nix-build ‘\<nixpkgs/nixos\>’ -I ‘nixos-config=/etc/nixos/configuration.nix’ --no-out-link -A system

Afterward, the proxy was indeed disabled and nixos-rebuild able to run

Thanks.

---

<div class="post-metadata">

### Author: ![SRGOM](https://discourse.nixos.org/user_avatar/discourse.nixos.org/srgom/32/1688_2.png) [@SRGOM](https://discourse.nixos.org/u/SRGOM)
#### Post date: [February 10, 2020, 3:18pm UTC](https://discourse.nixos.org/t/disable-proxy/5295/11 "2020-02-10T15:18:31Z")

</div>

I don’t recall the exact syntax/semantics buy there is a clone thingy which you probably want

---

<div class="post-metadata">

### Author: ![randomninja](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/r/ecccb3/32.png) [@randomninja](https://discourse.nixos.org/u/randomninja)
#### Post date: [March 5, 2025, 10:56am UTC](https://discourse.nixos.org/t/disable-proxy/5295/12 "2025-03-05T10:56:07Z")

</div>

In case someone ran to this issue like me, you could also try removing the `networking.proxy` configurations and running `nixos-rebuild` with `--offline` option:

```shell
$ nixos-rebuild switch <your-other-options> --offline

```

---

<div class="post-metadata">

### Author: ![DasBrain](https://discourse.nixos.org/user_avatar/discourse.nixos.org/dasbrain/32/37821_2.png) [@DasBrain](https://discourse.nixos.org/u/DasBrain)
#### Post date: [July 2, 2026, 1:25pm UTC](https://discourse.nixos.org/t/disable-proxy/5295/13 "2026-07-02T13:25:24Z")

</div>

```bash
$ sudo systemctl –runtime edit nix-daemon

```

might be better here. This will place the `override.conf` below `/run`.

> If `--runtime` is specified, the changes will be made temporarily in `/run/` and they will be lost on the next reboot.

And also

> ```auto
> --runtime
> When used with enable, disable, edit, (and related commands), make changes only temporarily, so that they are lost on the next reboot. This will have the effect that changes are
> not made in subdirectories of /etc/ but in /run/, with identical immediate effects, however, since the latter is lost on reboot, the changes are lost too.
> 
> ```

Note that those changes persist across a `nixos-rebuild` until you reboot your machine, so I’d recommend rebooting the machine once those temporary changes are no longer needed. (Or manually undoing it.)
