R
Railway•14mo ago
iseiaki

connect: connection timed out

connection timed out when I try to connect to the mysql database that I setup on railway. I'm using golang.
db, err := gorm.Open("mysql", "username:password@tcp(containers-us-west-62.project.app:port)/db")
if err != nil {
panic(err)
}
defer db.Close()
db, err := gorm.Open("mysql", "username:password@tcp(containers-us-west-62.project.app:port)/db")
if err != nil {
panic(err)
}
defer db.Close()
what could be wrong?
30 Replies
Percy
Percy•14mo ago
Project ID: N/A
iseiaki
iseiakiOP•14mo ago
N/A
Brody
Brody•14mo ago
what driver are you using
iseiaki
iseiakiOP•14mo ago
wym by driver I'm using gorm for mysql
Brody
Brody•14mo ago
the SQL driver
iseiaki
iseiakiOP•14mo ago
yeah gorm
Brody
Brody•14mo ago
that's an orm, not a driver
iseiaki
iseiakiOP•14mo ago
how do I see the driver then
Brody
Brody•14mo ago
you would have imported a driver, what driver did you import
iseiaki
iseiakiOP•14mo ago
my imports
"os"

"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
"os"

"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
Brody
Brody•14mo ago
increase the connection timeout
iseiaki
iseiakiOP•14mo ago
I just increased it to 60secs, let's see just checked gorm automatically uses the go-sql-driver 60 seconds failed
Horserix
Horserix•14mo ago
In gorm docs it says to use user instead of username, right? 🤔 In the example it says: user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local and in yours says username:pass
iseiaki
iseiakiOP•14mo ago
thats just a placeholder u gotta put the real credentials to connect
Horserix
Horserix•14mo ago
oh nvm my bad lol. Just thought it could be a typo
Brody
Brody•14mo ago
can you connect to the database from something like mysql workbench
iseiaki
iseiakiOP•14mo ago
I've connected to the db from my local xampp server successfully both locally and when hosted on railway don't work
Brody
Brody•14mo ago
not quite what i was asking can you connect to the railway database from something like mysql workbench
iseiaki
iseiakiOP•14mo ago
tried. doesn't connect
Brody
Brody•14mo ago
are you sure you are using the correct credentials?
iseiaki
iseiakiOP•14mo ago
will check again
Brody
Brody•14mo ago
and then try to restart the plugin
iseiaki
iseiakiOP•14mo ago
still not connecting, will delete this one and spin up a new one fixed finally
Brody
Brody•14mo ago
lol okay i didnt know just deleteting a database was an option for you, guess you didnt have any data on it
iseiaki
iseiakiOP•14mo ago
did have data ofc, export > import :__)
Brody
Brody•14mo ago
railway doesnt have native export and import, so good on you for doing that yourself
iseiaki
iseiakiOP•14mo ago
yup, hooked it up on the local xampp :PPP
Brody
Brody•14mo ago
cool, so all good?
iseiaki
iseiakiOP•14mo ago
yup, thanks for the help
Brody
Brody•14mo ago
no prob 🙂
Want results from more Discord servers?
Add your server