Trouble connecting Heroku App with Amazon RDS Instance

依然范特西╮ 提交于 2019-12-11 00:41:12

问题


I'm using Amazon RDS for the first time ever and I've been following the heroku docs to get my app using the RDS instance. So far I've created an instance and I have setup the addon using the format:

$ heroku addons:add amazon_rds url=mysql://user:pass@rdshostname.amazonaws.com/databasename

After running heroku rake db:migrate I got

!!! The bundled mysql.rb driver rake aborted! no such file to load -- mysql

So I installed the MySQL gem. Doing the same thing again I got the error:

Can't connect to MySQL server on 'myapp.cqslpaxxqrok.eu-west-1.rds.amazonaws.com' (110)

I see there's a note about the instance being in the US-east region for Heroku's security group to control access or something. Can I not use a European instance?


回答1:


Heroku changed its procedure to allow Heroku servers to connect to RDS instances. The accepted answer to this question is not true anymore.

You have to grant Heroku dynos access to your RDS instance. The recommended way to do this is to configure the RDS instance to only accept SSL-encrypted connections and configure the security group for your instance to permit ingress from all IPs.

Previously, Heroku published its AWS account ID and security group name as a way to grant access to an AWS RDS instance. This is no longer recommended.

Ref: https://devcenter.heroku.com/articles/amazon_rds




回答2:


No, you cannot use a European instance. Heroku is only available on the US East zone right now, and you need to be able to add Heroku to your security zone for the RDS instance to work, which I suppose require you to be in the same zone. More imporantly, you want to be in the same zone as Heroku for latency and security reasons (otherwise your database traffic will be travelling over the Internet).



来源:https://stackoverflow.com/questions/3969272/trouble-connecting-heroku-app-with-amazon-rds-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!