When running a script:

brownie run scripts/deploy.py --network kovan

I receive this error:

raise ValueError(f"Unable to expand environment variable in host setting: ‘{uri}’”)
ValueError: Unable to expand environment variable in host setting: ‘https://kovan.infura.io/v3/$WEB3_INFURA_PROJECT_ID

What am I doing wrong?

5 Answers 5


Typically, this means your environment variables are not set correctly, and it looks like in this case it's your WEB3_INFURA_PROJECT_ID.

Solution 1

You can fix it by setting the variable in your .env file and adding dotenv: .env to your brownie-config.yaml.


dotenv: .env



Remember to save these files.

Additionally, you should be on at least brownie version v1.14.6. You can find out what version you're on with:

brownie --version

Solution 2

If you know how to set environment variables you might want to check if you're setting them correctly. If you're on a linux-like environment, you can do:

source .env

To set them.

  • Hi, where do you find all the possible env variable fro brownie? I mean, How can someone know about the existance of WEB3_INFURA_PROJECT_ID?
    – anon
    Sep 14, 2021 at 13:14
  • 1
    You'll have it in your .env file. You don't want others to be able to see that file though, otherwise they could make API calls to infura. Sep 14, 2021 at 18:17
  • Yes, I know, I'm asking how do you know that that KEY has a meaning for brownie, I mean, in the documentation I can't find reference to that env Key
    – anon
    Sep 14, 2021 at 18:44
  • Good question, it's built in to brownie. Check here: eth-brownie.readthedocs.io/en/v1.0.1/… Sep 14, 2021 at 19:12
  • Thank you, i really have those env variable that are hidden and not documented (e.g. ETHERSCAN_TOKEN that is used to publish the source code in etherscan, it's not reported)
    – anon
    Sep 15, 2021 at 10:48

I've had this error for days and have seen it posted alot online. I was simply 1 directory up from where I needed to be - I followed the Patrick Collins tutorial very closey with the addition of setting up a virtual env, so maybe others are simply having the same problem I had.

I was originally in a directory "\demos\web3 brownie" which contained a folder called "brownie" and my python virtual env files.

The script is now running when I'm in directory "\demos\web3 brownie\brownie" which contains the brownie build, script, contract directories


Sometimes it can be as simple as a typo error, such as improperly naming your files, such as "browni-config.yaml" when it should be "brownie-config.yaml".


if you are sure you set the .env correctly you can try sourcing your .env file in the terminal:

source .env

and then try running your script again.


I was having the same problem as you , also with PRIVATE_KEY associating. What I've done is copy the .env field in the scripts folder , adding also dotenv : .env to brownie-config.yaml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.