R
Railwayβ€’11mo 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β€’11mo ago
Project ID: N/A
iseiaki
iseiakiβ€’11mo ago
N/A
Brody
Brodyβ€’11mo ago
what driver are you using
iseiaki
iseiakiβ€’11mo ago
wym by driver I'm using gorm for mysql
Brody
Brodyβ€’11mo ago
the SQL driver
iseiaki
iseiakiβ€’11mo ago
yeah gorm
Brody
Brodyβ€’11mo ago
that's an orm, not a driver
iseiaki
iseiakiβ€’11mo ago
how do I see the driver then
Brody
Brodyβ€’11mo ago
you would have imported a driver, what driver did you import
iseiaki
iseiakiβ€’11mo 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β€’11mo ago
increase the connection timeout
iseiaki
iseiakiβ€’11mo ago
I just increased it to 60secs, let's see just checked gorm automatically uses the go-sql-driver 60 seconds failed
Horserix
Horserixβ€’11mo 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
iseiakiβ€’11mo ago
thats just a placeholder u gotta put the real credentials to connect
Horserix
Horserixβ€’11mo ago
oh nvm my bad lol. Just thought it could be a typo
Want results from more Discord servers?
Add your server