Brownie doesn't automatically attach to local ganache when I have Ganache open in the background. It is stuck with ganache-cli (1st image) (2nd image is what I am looking for). Can someone help?
-
Remember to accept the working answer below – Baboo Jun 18 '22 at 17:01
4 Answers
Check that the port numbers are the same between GUI and CLI. I was able to fix by going into Ganache (GUI) settings -> server and reset the port to 8545
. Save and restart. Brownie should attach next time you run your deploy script.

- 406
- 4
- 3
The other solution is adding your local Ganache GUI account to the brownie networks list. To do that first you need to gather your host and chainid:
brownie networks add {network_class} {your_network_name} host={your_host} chainid={your_chaid}
Here, you have to change values between {}. For instance:
brownie networks add Ethereum ganache-local host=http://0.0.0.0:8545 chainid=1337
This command creates a new local network named 'ganache-local' on host 'http://0.0.0.0:8545' with '1337' chainid value in Ethereum class
To use this network on brownie commands, you need to set network flag to you network name. For instance I've created a network with the name of 'ganache-local' I can use this network like:
brownie run scripts/deploy.py --network ganache-local
With this way, you also can track your deployments on this network in deployments folder.

- 355
- 2
- 15
It seems to be attached to the Ganache that you are running, as its stated there. Ganache GUI opens up the instance of ganache-cli

- 1
-
As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 04 '21 at 15:50
I met the same problem. After I switch the port number from 7545 to 8545 in Ganache setting (the top right corner)---->Server---->Port Number. The problem was just solved. Brownie can attach to local Ganache by '127.0.0.1:8545'.
Hope this helps

- 1
- 1