Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku cleardb connection default addr for network unknown

I have created a free instance of Heroku cleardb instance for my app. I set the database URL as:

heroku config:set DATABASE_URL='mysql://user:[email protected]/heroku_database?reconnect=true'

I'm trying to connect using a Go app. But when I try to access my application, it gives the following mysql error:

default addr for network 'us-cdbr-iron-east-03.cleardb.net' unknown

I tried to set the database url with protocol and port as well:

heroku config:set DATABASE_URL='mysql://user:pass@tcp(us-cdbr-iron-east-03.cleardb.net:3306)/heroku__database?reconnect=true'

This changes the errror to:

Access denied for user

which i'm guessing is because direct access to port is disallowed. Does anybody know what is the issue here?

like image 259
abhink Avatar asked Dec 06 '25 15:12

abhink


1 Answers

This is a Go specific problem. Three changes are required:

  1. Go's sql.Open already takes scheme as its first parameter so it needs to be stripped off of DATABASE_URL.
  2. Connection string shouldn't have any query parameters (remove ?reconnect=true).
  3. Protocol (tcp) and port (3306 for MySQL) number are required.

Thus final database URL would be:

DATABASE_URL='user:pass@tcp(us-cdbr-iron-east-03.cleardb.net:3306)/your_heroku_database'
like image 197
abhink Avatar answered Dec 09 '25 12:12

abhink



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!