Flatpak apps not (automatically) using system proxy (set from GNOME Settings)

In gnome settings, I have set up a manual proxy. On this particular network, without the proxy, I cannot access the internet.

  • Running firefox natively uses the proxy and I can access the internet. Proxy also works for gnome-software (native package, not flatpak).
  • Running flatpak run org.mozilla.firefox does not use the proxy and internet is unavailable.
  • However, running http_proxy="$http_proxy" https_proxy="$https_proxy" flatpak run org.mozilla.firefox does use the proxy and I can access the internet. Note that $http_proxy and $https_proxy were not set by me, they are set automatically when I set up the proxy from GNOME Settings.

Similar observation with Signal (messaging) app.

  • flatpak run org.signal.Signal does not use proxy
  • http_proxy="$http_proxy" https_proxy="$https_proxy" flatpak run org.signal.Signal uses proxy correctly.

Discord, however, does not use proxy either way.

  • flatpak run com.discordapp.Discord does not use proxy
  • http_proxy="$http_proxy" https_proxy="$https_proxy" flatpak run com.discordapp.Discord does not use proxy.
  • http_proxy="$http_proxy" https_proxy="$https_proxy" ftp_proxy="$ftp_proxy" all_proxy="$all_proxy" flatpak run com.discordapp.Discord does not use proxy.

Any solutions how to make proxies work consistently accross flatpak apps?

Fedora version: 39
GNOME version : 45.4
Flatpak version: 1.15.6
All flatpak apps mentioned in this post are from flathub.org repository

Try setting those proxy settings within your environment so that every time you log in they are set automatically. Once done you should not need to use those settings on the command line. The command export https_proxy http_proxy should put both those variables into the environment.

I have no clue about the difference between discord and the others, but it must be related to how discord accesses the internet and/or its use of proxys.

Also look at the actual value of $http_proxy and $https_proxy (as an example echo $http_proxy would show that value). It may give you a clue on how to set that permanently in your environment.

I think that ~/.bash_profile can be used for non-login gui and ~/.bashrc works for terminal (login) sessions.

I cannot do that. This proxy is specifically required for accessing internet through one particular WiFi network, so I can not hard-code the environment variable at login. If I do that, I will not be able to use other networks that do not require the proxy. These environment variables are dynamically set/unset when I toggle the proxy on/off from gnome-settings and I need these toggles to work.

Then script a command that allows use of each app – one script using the proxy and one not using the proxy.

Yes that is possible. I can put

alias flatpak='http_proxy="$http_proxy" https_proxy="$https_proxy" ftp_proxy="$ftp_proxy" all_proxy="$all_proxy" flatpak'

in ~/.bash_profile but in that case I will have to always launch these apps from the terminal whenever I want to use a proxy. To also have it take effect from GUI launches, I will manually have to clone desktop-entries from each app to ~/.local/share/applications/ and modify them one by one to use these environment variables. This will be unreasonably tedious if there are more than a handful apps that require these modifications.

Is there no other more elegant solution? Can I not somehow make flatpak read these environment variables automatically? Maybe using FlatSeal? Or is this a problem with flatpak itself?

flatpak override --env=variable=value
flatpak override --unset-env=variable

You can also set global variables in flatseal.

You may be able to script something with network manager dispatcher to do this dynamically.


1 Like

Thanks for your input. I am aware of overriding env-vars using flatpak override or flatseal. But this is something I cannot do because I do not want to hardcode values for $https_proxy. These values are set/unset dynamically by GNOME when I toggle the proxy on/off from Settings and I want to be able to toggle it on and off.

So something like running flatpak override --env=... everytime I connect to this particular network by matching the UUID, and then removing these overrides when connecting to a different network? Would work, thanks!

However, I doubt this is the inteded usage. I would not expect, for example, a non-geeky friend to be able to do this, or even figure out why the proxy doesn’t work. Can someone affirm that this is a bug or oversight from flatpak’s sight and whether I should file a bug report?

This is very surprising to me. I’m not sure how that’s even possible. Changing the settings in System Settings should only affect your gsettings values, not environment variables. I’ve tested just now and that certainly doesn’t happen to me; after configuring an HTTP proxy, the $http_proxy and $HTTP_PROXY environment variables remain unset. Those environment variables are intended for manual use.

The expected way for flatpak applications to read your proxy settings is to use the proxy resolver portal. This will be handled transparently if you use GProxyResolver, which basically all GNOME applications will do. Third-party applications might need code changes for that to work, though. You might need to use the environment variables as a workaround for broken applications.

1 Like

The variable changes do not reflect on running terminals. So when you turn on a manual proxy and for example set all proxys (from gnome-settings) to and port to 12345. Now close all instances of the terminal emulator (in my case it is gnome-console). Make sure all windows and running processes of the terminal emulator are closed. Then, re-open a a terminal and do an echo $http_proxy. It should output Similarly for other variables. I was also surprised at how it works but it does. It is possible that this is being set by the terminal emulator after reading the gsettings values. Tested on gnome-console and gnome-terminal, may or may not work on other terminal emulators.

So flatpak is not at fault here, the problem is that these apps are not using the appropriate portals for reading proxy settings. For now I will switch over to the native rpm version of firefox, and for other apps I will just launch them from gnome-console. Thanks!

Yes, that’s exactly right. I finally remembered that gnome-terminal has custom code to read the proxy settings and set the environment variables manually. gnome-console (kgx) probably does too. But I’m using Ptyxis. So that explains why it works for you but not for me.

1 Like

It looks to me like the environment variables used for the proxy are not being picked up by the flatpak so the user needs to explicitly set those variables when the flatpak is launched.

This seems to be part of the sandboxing that is done (in limited fashion) for some flatpaks and that would be the hurdle that must be overcome.


1 Like