Why does my application's IP address not change on subsequent requests? - heroku

As far as I know, Heroku has dynamic outbound IP addresses. But when I try to make a PHP script that requests https://ipinfo.io/ip via curl the IP doesn't seem to change.
When I push new commits the IP address does change, and when I run heroku run bash and run curl from there I always see a new IP.
Why does the IP not change when I run my PHP script from my browser, but it does change when I run curl via bash?

When you run something via heroku run it runs in a one-off dyno. This dyno is separate from the dyno(s) where your web server is running. It will therefore have a different IP address. Each time you run heroku run bash you get a brand new one-off dyno, resulting in a new IP address.
When I push new commits the IP address does change
Similarly, pushing changes to Heroku causes a new slug to be built and your application to be restarted.
You should be able to see similar behaviour if you simply restart your application, e.g. via heroku restart.

Related

Host heroku changes with each code loaded or when reloading the service

I have an application on heroku and I try to connect and fetch information from a remote database. I need to give permission on that remote database, informing the host, but every time I load new code in the heroku app, with heroku cli, or when it goes down and restarts the service, it changes the host origin in the request as described below :
Access denied for user 'bpgea023_teste'#'ec2-44-203-99-231.compute-1.amazonaws.com' (using password: YES)
Informing the host in this snippet, ec2-44-203-99-231.compute-1.amazonaws.com
I don't use paid Dyno, and I didn't do any DNS configuration, I expected the source host to be the same auto-generated one, like app-test.herokuapp.com
Have any solution for this?
If you have the % wildcard possibility, the solution is %.amazonaws.com, putting that as permissive host.

Shopify CLI - How to start a local server without ngrok?

My organization blocks ngrok, so every time I run the Shopify serve command, it fails with a connection error.
So is there any way to just start the Shopify local server? that way I can use cloudfared to tunnel the local server to a subdomain.
When I search on google I found no answer to this question.
I had success running the server without the ngrok.
Here are my steps:
Prepare a cloud server, install Nginx.
config domain settings, and forward the request to your local port.
If you are using a router, only router has a public IP, so you need to forward the request to your pc. You could config it in the router.
then you need to update .env file, update host value
Go partner.shopify.com, app settings. put your URL to the whitelist.
use npm run dev to start your project.
I also set HTTPS in nginx. Due to ngrok server is far away from my location. so after using this way. the starting time is much faster.
Start the server by
npm run dev
instead of,
shopify app serve

Why does this heroku-hosted java app return 404?

I have a .jar file that listens for requests and streams music (lavalink). When I run it locally on my own computer, I can make requests to it and everything works fine. However, when I move it to be hosted on heroku, trying to send a request to the app just results in nothing happening.
I am using "https://my-app-name.herokuapp.com" as the hostname to connect to, and the port I am using is the one that shows up in the logs:
Starting process with command java -Dserver.port=27955 -jar Lavalink.jar
^this one
Am I doing something wrong? Can Heroku maybe not find the java app? Do I need to provide a different hostname or port?
Turns out that Heroku always listens on port 80 for external requests and then routes the traffic to the port that shows up in the logs. Rewriting the config file (that the java app uses) during build to use the port that shows up in the logs seems to work.

Force changing the ip of the Heroku dyno

I am wondering if there is a way to reset the dyno IP on Heroku when I want.
I noticed sometimes it changes when the application is restarted. However, not always.
How can we reset the dyno IP address on restart every time?
I already saw these questions:
Does Heroku change dyno IP during runtime?
https://www.quora.com/Do-Heroku-dynos-get-new-IP-addresses-when-redeployed-or-restarted
It turns out by restarting the app (deleting the dynos), the IP is changed, by default.
You can do this by using the Heroku API.

MEAN stack click-to-deploy Google cloud platform

I'm trying to deploy a MEAN stack app on Google Cloud platform using their functionality "click-to-deploy". Once my VM is created, I can ssh to it, clone my git repository and run my server. My app is accessible at the given IP address on the right port. Everything works fine until I end my session which automatically stops my server. How can I make sure node will still be running afterwards ?
A better way to do it would have been to use the command forever start

Resources