Short answer: you cannot. You will have to switch hosts.
Longer answer: if the VPN software is available for Linux, you can theoretically provide it to the hero with custom buildpack , and then use this from your application. However, this is a fairly significant event.
EDIT: j_mcnally makes a very good point that I forgot about. The builder will probably not work, because even if you provide the software, it is unlikely that you will be able to create the tunnel adapters or adapters necessary for it to work.
My last suggestion was to host a proxy server somewhere outside the Heroku infrastructure and bounce off of it in order to access the database through a VPN. Maybe host it on EC2, as you can at least put your proxy in the same availability zone.
source share