Error loading .env file
I tried the free trial to deploy my golang code then I encountered that problem in the deploy logs. even though I've added the environment variable in the railway. is there anything i missed?
38 Replies
Project ID:
N/A
screenshot of your service variables please
is that what you mean?
please remove all database related variables and add them back with variable references
https://docs.railway.app/develop/variables#reference-variables
and another screenshot when youve done that please
like this? and the value just like that?
correct, keep doing that for all of them
make sure to cancel the popup in the bottom right corner
like this?
but i dont understand what u mean
now wrap your godotenv code in this if block
reason being, you do not need to load an .env file on railway, as railway injects all the variables into the environment for you
once you've implemented that code, show me a screenshot of that code in your code
wait thats my code, so what should i do is copy line of 35 til 38 paste to 41 ? or copying line of 44 til 49 paste to 41 ?
one sec, ill type it out for you
and show me a screenshot when you have implemented this code block please
like this?
full screenshot please
looks good
so should i run again im my terminal?
nothing changes locally, push the code to github
side note: i see you're building the dsn string manually, i highly recommend this package to parse the
MYSQL_URL
variable and return a dsn string
https://github.com/xo/dburli see, thank you so much
but its already working
thank you 🙂 i have spent my time for solve this with my self
thank youu again
no problem!
have you generated a domain?
no, im sorry but idk a lot about this actually. because this for my assignments in college. so how can i get it?
go to your service settings and click generate domain
thats a local address
yes i mean, get the domain for public ?
i see
i get it
i suspect there is another issue?
yes it cant
why?
1. use https
2. set a service variable PORT = 8080
u mean that one i have to change to be 8080?
like that?
indeed
it works
thank u so much
no problem 🙂