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