Env variables not working on my app

I tried everything. Nothing makes my go app be able to get env variables.

flyctl config display

shows the expected env but when app tries to retrieve it just cannot find.

can someone help?


That’s strange. I’d start by hard-coding in a test one. You can add a plain text key/value in your fly.toml file. See this section:

Having done that, before even looking at any app/code, I’d see if they are available to your VM/machine. You can see by running fly ssh console and then e.g echo $EXAMPLE (or whatever you call it)).

If you can see your environment variable’s value, Fly’s part in this process is done. It provided the variable to the VM. What you do with it is your app/code’s job. If the variable is there but your code isn’t loading it correctly, that suggests an issue with your code.

This may be complicated by confusing build-time environment variables with run-time environment variables. The ones provided in env (and by using fly secrets) are made available at run-time and so could be undefined at build-time.