# \[ERROR\] Unable to load config from environment variables.

**URL:** <https://community.hubspot.com/t/error-unable-to-load-config-from-environment-variables/64208>\
**Category:** CMS Development\
**Created:** [August 31, 2022, 6:59pm UTC](https://community.hubspot.com/t/error-unable-to-load-config-from-environment-variables/64208 "2022-08-31T18:59:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![grandoompa](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@grandoompa](https://community.hubspot.com/u/grandoompa)\
**Post date:** [August 31, 2022, 6:59pm UTC](https://community.hubspot.com/t/error-unable-to-load-config-from-environment-variables/64208/1 "2022-08-31T18:59:23Z")

</div>

Hi, I successfully added a Sandbox connection to my hubspot.config.yml by using “npx hs auth”. I can now switch between production and sandbox, but when I ‘hs watch’ using the sandbox account, I get the following error:  
[ERROR] Unable to load config from environment variables.  
I’ve never created any kind of env variables myself, so I’m stumped what or where the error is referring to.  
My changes are still geting uploaded to my sandbox when watching, but that error message persists and I can’t seem to understand why I’m getting it.  
I’m using Node 16, but when I downgrade to Node 10 (out of curiosity), the error doesn’t appear.  
Any thoughts?

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [September 1, 2022, 11:09pm UTC](https://community.hubspot.com/t/error-unable-to-load-config-from-environment-variables/64208/2 "2022-09-01T23:09:36Z")

</div>

Hi, @grandoompa 👋 Thanks for reaching out. Let’s see if we can get things moving for you. Hey, @Gonzalo @Indra @LMeert, can you provide any help or tips on how to approach the error @grandoompa is experiencing?

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![TamikoTerasawa](https://avatars.discourse-cdn.com/v4/letter/t/dc4da7/32.png) [@TamikoTerasawa](https://community.hubspot.com/u/TamikoTerasawa)\
**Post date:** [September 14, 2022, 2:11am UTC](https://community.hubspot.com/t/error-unable-to-load-config-from-environment-variables/64208/3 "2022-09-14T02:11:12Z")

</div>

Hi, [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) , I’m getting the same error after updating Hubspot CLI to 4.0.1. With 4.0.0, I don’t get any errors.

Any help would be appreciated.

Thank you.

---

<div class="post-metadata">

**Author:** ![JBrake](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jbrake/32/76513_2.png) [@JBrake](https://community.hubspot.com/u/JBrake)\
**Post date:** [October 3, 2022, 11:28pm UTC](https://community.hubspot.com/t/error-unable-to-load-config-from-environment-variables/64208/4 "2022-10-03T23:28:25Z")

</div>

I am experiencing the same thing. Any command in the CLI seams to generate the message (watch, fetch, list), though I’ve not found it stop anything I am trying to do, so… far… but it is a bit of a concern that I am getting it in any case.

---

<div class="post-metadata">

**Author:** ![RobertMarinho](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/robertmarinho/32/86506_2.png) [@RobertMarinho](https://community.hubspot.com/u/RobertMarinho)\
**Post date:** [September 6, 2022, 1:17pm UTC](https://community.hubspot.com/t/error-unable-to-load-config-from-environment-variables/64208/5 "2022-09-06T13:17:22Z")

</div>

I’m getting the same error on the production portal only. (not getting It on the sandbox account).

Different from you I’ve defined some env variables with the hs secrets command.

Not only watch or upload commands but any other hubspot CLI command that tries to connect with the portal produces the same error message like:

**hs secrets list --account=**

I’m looking for a solution too.

Thanks!

---

<div class="post-metadata">

**Author:** ![RobertMarinho](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/robertmarinho/32/86506_2.png) [@RobertMarinho](https://community.hubspot.com/u/RobertMarinho)\
**Post date:** [September 6, 2022, 3:47pm UTC](https://community.hubspot.com/t/error-unable-to-load-config-from-environment-variables/64208/6 "2022-09-06T15:47:18Z")

</div>

I tried something that fixed It for me.

I was getting the error only when I set the --account parameter.

So, in your hubspot.config.yml set the **defaultPortal** to the one you are working with at the moment you run ‘hs watch’ (sandbox or production).

Additionally you might change the **defaultPortal** with the command below:

`hs accounts use <account_name>`

I hope It helps you too.

Thanks!

---

<div class="post-metadata">

**Author:** ![grandoompa](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@grandoompa](https://community.hubspot.com/u/grandoompa)\
**Post date:** [September 8, 2022, 2:09pm UTC](https://community.hubspot.com/t/error-unable-to-load-config-from-environment-variables/64208/7 "2022-09-08T14:09:39Z")

</div>

Hi @RobertMarinho , Thank you very much for your input and suggestion. I appreciate it.  
So when I tried either “hs accounts use SANDBOX”, which I see updates my hubspot.config.yml, or manually changed the defaultPortal to SANDBOX and then “hs watch”, it seems the first save while watching gets uploaded to the SANDBOX account, but then my hubspot.config.yml immediately reverts back to PROD after the save/upload - the first account listed in my hubspot.config.yml. Note: I’m trying to switch between “PROD” and “SANDBOX” accounts in my hubspot.config.yml.  
So it seems that the change doesn’t stick. Did you encounter the same experience, by any chance?

---

<div class="post-metadata">

**Author:** ![RobertMarinho](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/robertmarinho/32/86506_2.png) [@RobertMarinho](https://community.hubspot.com/u/RobertMarinho)\
**Post date:** [September 12, 2022, 1:32pm UTC](https://community.hubspot.com/t/error-unable-to-load-config-from-environment-variables/64208/8 "2022-09-12T13:32:17Z")

</div>

Hi @grandoompa You’re welcome.

That’s an weird issue. I never experienced It.

Here are some options I would try in this case:

- Check if hubspot cli is updated to the most recent version.

- Recreate the _hubspot.config.yml_ file again with [hs auth](https://developers.hubspot.com/docs/cms/developer-reference/local-development-cli#auth).

- Try to separate the _hubspot.config.yml_ in 2 files: _hubspot.config.SANDBOX.yml_ and _hubspot.config.PROD.yml._ The run _“hs watch”_ passing the option --config to the account you’re working at:

`hs watch <src> <dest> --config=hubspot.config.SANDBOX.yml`

Thank you!
