cant connect to MariaDB

Im working on an ASP.NET REST API and I have setup MariaDB on WSL, now im trying to connect to it using ASP.NET from within a docker container but it tells me that its unable to connect. I have already verified that the environment variables are getting set properly
No description
No description
4 Replies
The Fog from Human Resources
this is my connection string btw private static string _connectString = $"Server={Utils.DatabaseServer};Port={Utils.DatabasePort};UID={Utils.DatabaseUser};PWD={Utils.DatabasePassword};";
jcotton42
jcotton426mo ago
is DatabaseServer by chance localhost? also, don't read env vars like that, use the config system https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/
Configuration in ASP.NET Core
Learn how to use the Configuration API to configure AppSettings in an ASP.NET Core app.
jcotton42
jcotton426mo ago
@Waffles from Human Resources if it is "localhost" then it's failing because localhost in the container refers to the container, not your machine ideally if you're going for a docker setup, then your database would also be in a container you can stand up and "wire" the containers together with docker compose
The Fog from Human Resources
I'll check it out tomorrow, and yes the local host refers to my local machine on WSL but it makes sense that it's trying to target the container Thanks!
Want results from more Discord servers?
Add your server