Can a Heroku app access remote database? - heroku

I want to host an application in Heroku bu don't want to use a Heroku database. Can I connect to an existing remote database from my Heroku app?

You can use whatever database you like from Heroku as long as it is accessible from Heroku's platform.
Just set and use the proper env var in your app with your db's address and credentials and it should just work.

Where is your current database hosted? In short, the answer is likely yes. Heroku makes it really easy to connect to an Amazon RDS instance through a plugin. This is the same way many other database hosts provide connectivity, such as ClearDB or MongoLab. If you share where your current remote database is, it will be easier to give you more information.

Related

Does Heroku provide any VPN client like AWS Client VPN?

I want to host a database in Heroku server and also a django application. The problem is: To transfer data to my Heroku database i would need be connected to a VPN. Does Heroku provides a way to connect to a VPN in order to access another database, like AWS client VPN?
My infra would be like this:
Airflow running DAGs to pull data from a AWS database that requires VPN connection to source from it. I would transfer the data from this AWS database to my heroku database.
Is it possible?
Thank you
Another thing that i'm wondering is if it is possible to connect Heroku to AWS client VPN, in case Heroku does not have something similar or a way to do this step.
Yes Heroku does provides a VPN labelled as Heroku Private Spaces and Shield Spaces.
Here is the link
https://devcenter.heroku.com/articles/private-space-vpn-connection

I don't have fixed IP address, how can I let others access my database?

I run Memgraph Platform on my laptop inside Docker container. When I'm at the office my colleague can access it, but when I work from home he can not get to the database. I don't have fixed IP address, and my ISP doesn't allow me to do port forwarding and dynamic DNS also doesn't work for me. What can I do to make my database accessible to others?
Try to follow the advice given by #Martheen. I have experience with running Tailscale for this purpose and it works.
I don't know why you can't deploy it to some server (if there are regulation issues or company policies in question) but if it is not any of those maybe you could use Memgraph Cloud and host your data. That way you would be sure that everyone with the right credentials could access your data. But it all depends on your setup and usage scenario. Since you are using Docker I presume that you have all of your environment configured right the way that you want on your laptop.

work remotely on heroku with vscode and commit changes

I want to code directly on production with VSCode, make some changes, and commit them (for fast prototyping, not a live server). I'm testing responses from external services, so I need a publicly-accessible URL.
Is that possible with heroku?
When I SSH intro Heroku from a terminal, I can't git commit cause I get fatal: not a git repository
Also, running heroku ps:exec on VSCode remote extension pack doesn't work.
No, this is not possible on Heroku without some very awkward hoop-jumping. Heroku is a platform-as-a-service provider, not a remote workstation.
I'm testing responses from external services, so I need a publicly-accessible URL
Your best bet may be to use something like ngrok or localtunnel.
These tools let you temporarily route traffic from a publicly-accessible address to your local development environment. At a high level, it looks something like this:
Start your development server locally
Start ngrok or localtunnel locally
Take the publicly-accessible URL the tool gives you and tell the external service to use it

Heroku CLI gives "No Redis instances found" yet I have a redis cloud addon running and usable

I'm learning redis and have it working from a java app. I'm trying to use the heroku redis:cli -a myAppName command to connect with it directly but it says "No Redis instances found".
When I do heroku apps it lists myAppName so I know it's valid.
heroku redis:info -a myAppName doesn't return anything.
The heroku docs don't seem to be accurate as they all leave out the -a flag which the cli tells me is required. Outside of that I don't know what I've missed.
You are looking at documentation for Heroku Redis, a hosted Redis service that Heroku itself provides. If you wish to use Heroku Redis, you can provision it for your app using like so:
heroku addons:create heroku-redis:hobby-dev -a your-app-name
Pricing for Heroku Redis can be found here. The Hobby Dev plan used in the previous command is free.
There are also other Redis providers that can be provisioned this way, including Redis Enterprise Cloud. Or you can use existing hosted Redis server. But with these options you won't be able to interact with the service using heroku redis commands. Use whatever tooling those providers offer.

How to use your own mysql database server with heroku?

I want to use mysql database which is hosted on my own server.
I've changed DATABASE_URL and SHARED_DATABASE_URL config vars to point to my server, but it's still trying to connect to heroku's amazonaws servers. How do I fix that?
According to the Heroku documentation, changing DATABASE_URL is the correct way to go.
If you would like to have your rails application connect to a non-Heroku provided database, you can take advantage of this same mechanism. Simply set your DATABASE_URL config var to point to any cloud-accessible database, and Heroku will automatically create your database.yml file to point to your chosen server. The Amazon RDS Add-on does this for you automatically, though you can also use this same method to connect to non-RDS databases as well.
Here's an example that should work:
heroku config:add DATABASE_URL=mysql://user:password#host/db
You may need to redeploy by making a change and running git push heroku master
By the way, the host is XXXX.amazonaws.com, where XXX is a long host hame that probably changes. If you can add a wildcard, that's the easiest %.amazonaws.com
I had this exact same problem with my Dreamhost MySQL database. Turns out the solution was to tell Dreamhost is was Ok to accept connections from this foreign host. Otherwise, Dreamhost blocks all requests to MySQL that don't originate from their systems.
It seems that if Heroku is falling back to Amazon AWS despite your DATABASE_URL, it's because it's being denied access to your MySQL database.

Resources