I am using Golang to connect to a Postgres DB instance.
When the code below is executed from an Amazon EC2 instance, the error is not nil after sql.open()
.
db, err := sql.Open("postgres", "postgres://username:mypassword@xxxxxx.xxxxxxxxxx.xx-xxxx-x.xxx.xxxxxxxxx.xxx/postgres?sslmode=disable")
if err != nil {
check(err)
panic(err)
}
err = db.Ping()
if err != nil {
check(err)
panic(err)
}
However, when I run db.Ping()
it doesn't do anything. The code after db.ping()
doesn't seem to be executed. After a while I get getsockopt: connection timed out
in the terminal window.
What could be the problem? Also even when I use the wrong password, the error is still not nil
.