Skip to content

Instantly share code, notes, and snippets.

@mzpqnxow
Created August 24, 2020 04:45
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzpqnxow/ca4b4ae0accf2d3b275537332ccbe86e to your computer and use it in GitHub Desktop.
Save mzpqnxow/ca4b4ae0accf2d3b275537332ccbe86e to your computer and use it in GitHub Desktop.
Use SOCKS5 proxy with Discord on Linux

Using SOCKS5 Proxy With Discord on Linux

You may only need the environment or the command-line parameter to force Discord to use a proxy. It doesn't hurt to use both

So if you're behind a firewall and need to go through, e.g. an SSH dynamic port forward (a SOCKS5 channel inside an SSH session) you can use the following:

$ nohup ssh -D1080 proxy_server &
$ http_proxy=socks5://127.0.0.1:1080 https_proxy=socks5://127.0.0.1:1080 /opt/Discord/Discord --proxy-server="socks5://127.0.0.1:1080"

If you use some window manager in Xorg and it uses the .desktop style launch configurations (Xfce and probably others) using the following will accomplish the same thing for the context-menu / button launch:

$ cat .local/share/applications/discord.desktop
[Desktop Entry]
Name=Discord
StartupWMClass=discord
Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.
GenericName=Internet Messenger
Exec=env http_proxy=socks5://127.0.0.1:1080 https_proxy=socks5://127.0.0.1:1080 /opt/Discord/Discord --proxy-server="socks5://127.0.0.1:1080"
Icon=discord
Type=Application
Categories=Network;InstantMessaging;
Path=/tmp

The proxy URI can also be http://, https:// and possibly socks4://, socks4a:// or socks5h:// though I have not tested these

@axi92
Copy link

axi92 commented Jan 26, 2021

I tried it but it does not work, any updates on that?

@mzpqnxow
Copy link
Author

mzpqnxow commented Feb 6, 2021

I tried it but it does not work, any updates on that?

What behavior are you seeing? Also, have you tested from a terminal?

Depending on your window manager, changing the GUI menu entry may require a restart of the window manager before it takes effect

Also, obviously make sure Discord is completely dead before starting it with the new settings

I very rarely use Discord so it’s possible it no longer supports this- but that seems unlikely as I suspect the proxy feature may come built-in to the framework the app uses (though not sure)

@KaratekHD
Copy link

I can start Discord with this, but sadly, voice chat does not work

@elyograg
Copy link

elyograg commented Nov 3, 2021

Is there any way to ask discord to NOT use a proxy on Linux? I have a proxy defined at the system level (in gnome, I think). That proxy works perfectly for web browsing. When I first start the browser I do have to log in to the proxy. The proxy definition points to a PAC script, and that PAC script tells the browser when to connect directly and when to use the proxy.

I am not allowed to remove the proxy. It is a work requirement. I am trying to connect to a work-related discord server.

So what I want to know is how to tell DIscord not to use the proxy. Discord won't even start, with error net::ERR_TUNNEL_CONNECTION_FAILED

There are no environment variables set for the proxy. I don't know how gnome is communicating the proxy information to discord. I'm running Ubuntu 20.04.

@mzpqnxow
Copy link
Author

mzpqnxow commented Nov 3, 2021

Is there any way to ask discord to NOT use a proxy on Linux? I have a proxy defined at the system level (in gnome, I think). That proxy works perfectly for web browsing. When I first start the browser I do have to log in to the proxy. The proxy definition points to a PAC script, and that PAC script tells the browser when to connect directly and when to use the proxy.

I am not allowed to remove the proxy. It is a work requirement. I am trying to connect to a work-related discord server.

So what I want to know is how to tell DIscord not to use the proxy. Discord won't even start, with error net::ERR_TUNNEL_CONNECTION_FAILED

There are no environment variables set for the proxy. I don't know how gnome is communicating the proxy information to discord. I'm running Ubuntu 20.04.

You did env | grep -i proxy? I know you said no environment variables were set, but there must be something set somewhere. You can try (just for the heck of it):

$ http_proxy= https_proxy= ALL_PROXY= <command>

You could also try to explicitly tell discord to use an empty string as proxy, but it may not like that:

$ /opt/Discord/Discord  --proxy-server=

I'm not familiar at all with any Linux distributions having a "system level" proxy. You may have an Electron-wide proxy setting. I'm not too knowledgeable about Electron, but I noticed that Discord is an Electron-based app. You may get mileage out of this or this or just Google "electron proxy" or something similar

Good luck

@volodalexey
Copy link

On Linux Mint when Discord installed via flatpak (assume that you have socks5 client run on 7771 locally):

flatpak run com.discordapp.Discord --proxy-server="socks5://127.0.0.1:7771"

@pengshp
Copy link

pengshp commented Dec 11, 2023

sudo nvim /usr/share/applications/discord.desktop
Exec=/usr/bin/discord --proxy-server="socks5://172.16.10.18:7891"

@markxueyuan
Copy link

sudo nvim /usr/share/applications/discord.desktop
Exec=/usr/bin/discord --proxy-server="socks5://172.16.10.18:7891"

This configure does not work for my system. But running the same code directly in terminal does the job.

@MdNihal05
Copy link

Hey how can i use Proxy in my discord
It it provided by my college with some credentials like host:xxxx.ac.in username:xxxxx password:xxxxxxx
i can use proxy in terminal and browser but i can't use discord can you help me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment