failed opening connection to sql: default addr for network
Hi, I am trying to deploy my golang web service which connects to mysql. I have added the mysql url reference variable in my web service but currently see this error in my web service logs:
failed opening connection to sql: default addr for network
19 Replies
Project ID:
5b1457c9-94bf-4b38-9366-6949b7e8aa19
project id - 5b1457c9-94bf-4b38-9366-6949b7e8aa19
can I see a screenshot of your service variables please?
Sure only the one variable at the moment
looks good to me
show me the code that connects to the database please
still looks good
do you happen to be using the private network?
Not that I am aware of . New to railway to be honest.
Just created to new services, one the web app and another the mysql service.
then that's basically a no
go into the service settings and disable private networking
Thanks done that and redeployed but still no joy. Same error in logs.
hmmm
link me the library you are using for SQL and I'll see if I can whip something up
Appreciate your help.
https://entgo.io/docs/sql-integration/#use-pgx-with-postgresql
Using second option currently under configure sql.DB
sql.DB Integration | ent
The following examples show how to pass a custom sql.DB object to ent.Client.
I think I know the problem, so I will get back to you with a definitive answer soon
Amazing. Thanks again.
alright, so
sql.Open
wants a connection string in DSN format, you are providing a URL format and URL and DSN formats are not interchangeable, unfortunately railway doesn’t offer a DSN connection string variable so we have to construct our own.
set this service variable in the raw editor
and heres some example code
you of cource can still append your query parameters to mysqlDSN
like you where originally doingAhh good spot. I will give that a go now!
Brilliant worked a treat.
awsome
Thank you.
no problem!