R
Railwayβ€’13mo 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β€’13mo ago
Project ID: N/A
iseiaki
iseiakiβ€’13mo ago
N/A
Brody
Brodyβ€’13mo ago
what driver are you using
iseiaki
iseiakiβ€’13mo ago
wym by driver I'm using gorm for mysql
Brody
Brodyβ€’13mo ago
the SQL driver
iseiaki
iseiakiβ€’13mo ago
yeah gorm
Brody
Brodyβ€’13mo ago
that's an orm, not a driver
iseiaki
iseiakiβ€’13mo ago
how do I see the driver then
Brody
Brodyβ€’13mo ago
you would have imported a driver, what driver did you import
iseiaki
iseiakiβ€’13mo 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β€’13mo ago
increase the connection timeout
iseiaki
iseiakiβ€’13mo ago
I just increased it to 60secs, let's see just checked gorm automatically uses the go-sql-driver 60 seconds failed
Horserix
Horserixβ€’13mo 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β€’13mo ago
thats just a placeholder u gotta put the real credentials to connect
Horserix
Horserixβ€’13mo ago
oh nvm my bad lol. Just thought it could be a typo
Brody
Brodyβ€’13mo ago
can you connect to the database from something like mysql workbench
iseiaki
iseiakiβ€’13mo 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β€’13mo ago
not quite what i was asking can you connect to the railway database from something like mysql workbench
iseiaki
iseiakiβ€’13mo ago
tried. doesn't connect
Brody
Brodyβ€’13mo ago
are you sure you are using the correct credentials?
iseiaki
iseiakiβ€’13mo ago
will check again
Brody
Brodyβ€’13mo ago
and then try to restart the plugin
iseiaki
iseiakiβ€’13mo ago
still not connecting, will delete this one and spin up a new one fixed finally
Brody
Brodyβ€’13mo ago
lol okay i didnt know just deleteting a database was an option for you, guess you didnt have any data on it
iseiaki
iseiakiβ€’13mo ago
did have data ofc, export > import :__)
Brody
Brodyβ€’13mo ago
railway doesnt have native export and import, so good on you for doing that yourself
iseiaki
iseiakiβ€’13mo ago
yup, hooked it up on the local xampp :PPP
Brody
Brodyβ€’13mo ago
cool, so all good?
iseiaki
iseiakiβ€’13mo ago
yup, thanks for the help
Brody
Brodyβ€’13mo ago
no prob πŸ™‚
Want results from more Discord servers?
Add your server