Connecting to PythonAnywhere MySQL DB from Heroku?

Did anyone try this?

I understand that I should run the following command from the Heroku console:

heroku config:add DATABASE_URL=mysql2:// --app heroku-app-name

Is this a correct interpretation of the above? I'm a little bit uncertain what would be the IP for my PythonAntwhere db?


But how do I open access from Heroku to PythonAnywhere?

The reason why I want to connect from Heroku to PythonAnywhere is that the main code is at PythonAnywhere but a part of the project is Node.js and hence cannot be hosted here.


We do not expose our user databases to the internet. See

Hi Glenn,

I followed this guide and this is what I tried so far without success:

I successfuly opened SSH tunnel to PythonAnywhere in Heroku console:

ssh -L

I run:

heroku config:add DATABASE_URL=mysql2://PythonAnywhere-Username:PythonAnywhere-Password@PythonAnywhere-Database-Host-Address/ PythonAnywhere-Database --app Heroku-App-Name

I setup my MySQL-connection with the ENV var in my app.js:

var connection = mysql.createConnection({
   host     : process.env.DATABASE_URL,
   user     : PythonAnywhere-Username,
   database : "PythonAnywhere-Database",
   password : "PythonAnywhere-Password"
   multipleStatements: true

Can you see where I went wrong?

I don't know enough about Heroku or your app, but is it possible that the Heroku console where the SSH tunnel is and the place where your code is running are 2 different environments? If that was the case, you might not be able to see the tunnel from your app.