I am attempting to connect to Ganache GUI from WSL2 but assume that I have a firewall setting that is blocking the connection.
Has anyone set this up and has any advice?
I am attempting to connect to Ganache GUI from WSL2 but assume that I have a firewall setting that is blocking the connection.
Has anyone set this up and has any advice?
@abcoathup unfortunately, I donāt have much insight on this. I still use WSL as I havenāt had time to upgrade to WSL2.
Also, I havenāt used Ganache GUI since early this year. After learning that I could fork mainnet with Ganache CLI, I completely switched to that and removed the GUI.
Iām curious, how are you trying to connect the GUI to your WSL2 terminal? Is there an option for this in the GUI?
From what I recall when I was using the GUI, I always used a config file in my project directory that connected to the same port as the GUI for development. This was usually handled in a Truffle config file. I think the GUI defaults to port 7545, but should be visible on the GUI.
Or are you talking about interacting with the GUI directly from WSL2 without a config file or project directory? Iāve always had a project directory with web3.js or ethers.js installed to interact with the blockchain. Maybe you could install globally but Iāve never done this. If you have access to either of these libraries in the terminal though you can instantiate an instance of web3 and specify your provider in WSL2. For a local Ganache instance, this would be something like
var Web3 = require('web3');
var web3 = new Web3('http://localhost:7545');
or
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));
Not sure if this is very helpful. Iād love to help more if I can, but I just need more details on how youāre trying to connect the two.
Here are some resources I found on this:
Hi @Jshanks21,
I have Ganache GUI installed on Windows and was trying to access from WSL2.
I donāt have any issues connecting to ganache-cli
running on WSL2 so assume it is a firewall issue from node on WSL2 to Ganache GUI on Windows.
I had wondered if you had managed to set this up. Thanks for all the links.
I will probably just use node on Windows to connect to Ganache GUI on Windows until I get a chance to investigate further.
Hi @Jshanks21,
I just tried a DuckDuckGo search for āganache gui on wslā and this post is the top search result
Did you guys find any solution on how to use Ganache gui with wsl2. I only found this thread searching the internet.
Wsl2 is a great initiative by windows and it feels same as ubuntu speeds if your source code resides on ubuntu file system more than on the windows files (/mnt/c/Documents) . Wsl2 doesnt allow linux gui as of now. I found this article on how to setup linux gui in wsl2 but I didnt want to experiment with my new laptop.
https://itnext.io/using-windows-10-as-a-desktop-environment-for-linux-7b2d8239f2f1
Any help is greatly appreciated.
Hi @godfather,
Welcome to the community
I havenāt found/tried a solution. I am also reluctant to mess to much with my setup in case I kill my ability to work.
One option appears to be to use RDP and run a desktop on Linux. I donāt know what the experience would be like though:
Hi,
I just had this problem using Ubuntu under WSL 2 connecting to the Ganache windows GUI.
Installing ganache-cli locally worked fine (as hinted by @abcoathup, ta), but still could not connect āacrossā to the Ganache windows GUI.
Fix for me was to change the network settings from the default loopback interface to the WSL one. I also have to open the correct port up in Windows Firewall.
FWIW Iām on the dev channel of Windows Insider, so my WSL is bang up to date.
I was able to get the Ganache GUI in Windows to connect to a ganache-cli running in WSL2 (ubuntu 20). Start the ganache-cli in WSL2 first and then setup a Ganache Gui workspace in Windows after that, where the server is set to the ā0.0.0.0 - All Interfacesā host. This was the only way I could get it working
This worked for me. Thank you!
This also worked for me, it appears that the loopback address isn't connectible from wsl2
thanks for this bro, ahaha, it saves my day. lol
You guys are the best, this works flawlessly.
Protip: for anyone where this still doesn't work, once you start your ganache-cli and ganache gui application, make sure you change the port in the GUI to that of the CLI before you save and restart.
E.g. for me:
I think I might be trying to do the reverse. I have created a new truffle project on my WSL Ubuntu distro, and now I want to use Ganache GUI to view the state of my project. I couldn't get it to install on Ubuntu so I installed it on Windows 10. Is there a way to view my project on windows 10 when I have created it on Ubuntu with truffle init?
Thanks
Thanks a million !!!!
Thanks, it worked for me now
ANSWERED
to use Ganache on both Windows and WSL from ganache GUI of Windows.
goto your ganache setting > Server > HOSTNAME.
Set Value to 0.0.0.0 - All Interfaces
Then find your Wsl to windows ip address via this command (bash command)
grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'
and use that IP to write your RPC URL for WSL based connection like this
let provider = new ethers.providers.JsonRpcProvider(http://172.19.192.1:7545);
and for windows connection write simply with 127.0.0.1 like this
let provider = new ethers.providers.JsonRpcProvider(http://127.0.0.1:7545);