Here is an issue I am having with an app on Parse-Server (/Heroku).
I keep getting the message:
WARNING, Unable to connect to 'https://myapp.herokuapp.com/'. Cloud code and push notifications may be unavailable!
Here is the complete log I have when running the command: git push heroku master
2018-02-2...+00:00 app[api]: Build started by user me#xyz.com
2018-02-2...+00:00 app[api]: Deploy bduxedc8 by user me#xyz.com
2018-02-2...+00:00 app[api]: Build succeeded
2018-02-2...+00:00 app[api]: Release v25 created by user me#xyz.com
2018-02-2...+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-02-2...+00:00 heroku[web.1]: Process exited with status 143
2018-02-2...+00:00 heroku[web.1]: Restarting
2018-02-2...+00:00 heroku[web.1]: State changed from up to starting
2018-02-2...+00:00 heroku[web.1]: Starting process with command `npm start`
2018-02-2...+00:00 app[web.1]:
2018-02-2...+00:00 app[web.1]: > parse-server-example#1.4.0 start /app
2018-02-2...+00:00 app[web.1]: > node index.js
2018-02-2...+00:00 app[web.1]:
2018-02-2...+00:00 app[web.1]: parse-server-example running on port 23377.
2018-02-2...+00:00 heroku[web.1]: State changed from starting to up
2018-02-2...+00:00 heroku[router]: at=info method=GET path="/health" host=myapp.herokuapp.com request_id=fb429287-9b14-4373-97ab-30dac19a4db7 fwd="1.2.3.438" dyno=web.1 connect=2ms service=20ms status=404 bytes=217 protocol=https
2018-02-28T04:03:21.595649+00:00 app[web.1]:
2018-02-28T04:03:21.595660+00:00 app[web.1]: WARNING, Unable to connect to 'https://myapp.herokuapp.com/'. Cloud code and push notifications may be unavailable!
2018-02-28T04:03:21.595663+00:00 app[web.1]:
And if I change https to http in my configuration, I see exactly the same behavior.
Beside if I try to access to https://myapp.herokuapp.com/ in a browser I can do it with no problem.
I have read many post on the issue but nothing drove me to a solution.
That would be great if someone could let me know how to solve this.
I faced this issue and it might help someone in the future.
Note that this is one of the reasons why this warning might be thrown.
This is for parse server version: 2.8.2
To create your own standalone parse server, using express, the basic steps involved are close to:
Create a parse-server object with all your config like. For example: const api = new ParseServer(config);
config will contain the server URL along with all other requirements.
Create an express app object. For example: const app = express();
Then mount the parse server API on the express like -> app.use(mountPath, api);
And then create the server like: const httpServer = require('http').createServer(app);
And then start listening on a port like: httpServer.listen(port);
As soon as the mount is called, the parse-server will verify the url mentioned in the config by making a request to /health endpoint.
If for some reason there is a delay in listening to the port (point 6) after mounting the API (point 4), then the above warning will be thrown.
For example, in one case I was establishing a mongoose connection and only then started listening to the port. Because of this, the verification of URL from parse server failed, although everything worked fine after that.
And one of the possible solutions is to get done with all such work before mounting the parse API and ensuring no delay between mounting and listening to the port as described above.
While this may not be the exact steps for creating a parse server on heroku, the idea is that:
parse server will call verify url on the server url mentioned in the configs.
And if there is delay in starting the server after you have mouted the parse apis, the above warning will be thrown.
2018-02-2...+00:00 heroku[router]: at=info method=GET path="/health" host=myapp.herokuapp.com request_id=fb429287-9b14-4373-97ab-30dac19a4db7 fwd="1.2.3.438" dyno=web.1 connect=2ms service=20ms status=404 bytes=217 protocol=https
Notice status is 404, this doesn't exist, and the host says myapp.herokuapp.com
Do you perhaps have a server_url key set to literally myapp.heroku.com, or did you redact the name of your app?
Related
My backend was hosted on heroku for more than a month and was working fine. Now, today when i opened my website it shows this error in heroku logs.
heroku logs
`` 2022-11-26T13:59:37.770793+00:00 heroku[web.1]: Unidling 2022-11-26T13:59:37.773849+00:00
` 2022-11-26T13:59:37.770793+00:00 heroku[web.1]: Unidling 2022-11-26T13:59:37.773849+00:00 heroku[web.1]: State changed from down to starting 2022-11-26T13:`your text`59:40.671794+00:00 heroku[web.1]: Starting process with command `npm start` `2022-11-26T13:59:43.453482+00:00 app\[web.1\]:\`
2022-11-26T13:59:43.453508+00:00 app\[web.1\]: \> server#1.0.0 start
2022-11-26T13:59:43.453508+00:00 app\[web.1\]: \> node index.js
2022-11-26T13:59:43.453509+00:00 app\[web.1\]:
2022-11-26T13:59:43.936570+00:00 app\[web.1\]: Server started successfully on port 28406
2022-11-26T13:59:44.394629+00:00 heroku\[web.1\]: State changed from starting to up
2022-11-26T13:59:45.969634+00:00 app\[web.1\]: MongoDB Connected: ac-rbrrtx1-shard-00-02.hnnmtja.mongodb.net
2022-11-26T13:59:47.331529+00:00 heroku\[router\]: at=info method=GET path="/todos" host=to-do.herokuapp.com request_id=498c9348-ac27-4d03-98c5-ed9650e5b6d3 fwd="74.125.215.152" dyno=web.1 connect=0ms service=2501ms status=200 bytes=770 protocol=https
2022-11-26T14:35:38.862987+00:00 heroku\[web.1\]: Idling
2022-11-26T14:35:38.864646+00:00 heroku\[web.1\]: State changed from up to down
2022-11-26T14:35:39.633081+00:00 heroku\[web.1\]: Stopping all processes with SIGTERM
2022-11-26T14:35:39.834323+00:00 heroku\[web.1\]: Process exited with status 143
2022-12-02T12:31:11.037127+00:00 app\[api\]: Scaled to web#0:Eco by user api-maintenance#heroku.com
2022-12-08T18:34:07.067959+00:00 heroku\[router\]: at=error code=H14 desc="No web processes running" method=GET path="/robots.txt" host=to-do.herokuapp.com request_id=c7c564c9-6334-4140-bf27-6b0750093c26 fwd="5.255.253.147" dyno= connect= service= status=503 bytes= protocol=https\`\`
`
First, I would like to confirm whether you are using free plan of Heroku or not. Because Heroku stopped its free plan starting from November-26-2022.
For further information:
https://make.wordpress.org/plugins/2022/09/13/heroku-free-tier-being-retired/
If you have a paid version then it's a problem associated with dynos as the error is giving code H14 (last line). This is most likely the result of scaling your web dynos down to 0 dynos. Scale up your dynos to fix it.
For more information visit Heroku error codes:
Heroku error codes
This is the error:
Access to XMLHttpRequest at 'http://cheapandnice-backend.herokuapp.com/api/products/list'
from origin 'http://cheapandnice.herokuapp.com' has been blocked by CORS policy: No 'Access-
Control-Allow-Origin' header is present on the requested resource.
But I've already included the origin with cors:
const app = express();
app.use(
cors({
origin: process.env.ORIGIN,
optionsSuccessStatus: 200,
credentials: true,
})
);
process.env.ORIGIN is http://cheapandnice.herokuapp.com
I've tried with heroku local, which I think runs the code on heroku locally, and everything works just fine. As for my client I served the files locally with "yarn build" and then "serve -d build" and it works.
However this is what I get whem I run heroku restart and heroku logs --tail
2020-05-09T01:57:28.971077+00:00 heroku[web.1]: Restarting
2020-05-09T01:57:28.987996+00:00 heroku[web.1]: State changed from up to starting
2020-05-09T01:57:35.626755+00:00 app[web.1]: Server is running on port 41637
2020-05-09T01:57:35.629379+00:00 app[web.1]: [db] Cannot read property 'split' of null
2020-05-09T01:57:36.571910+00:00 heroku[web.1]: State changed from starting to up
and when I make a request
2020-05-09T02:00:04.559800+00:00 heroku[router]: at=error code=H12 desc="Request timeout"
method=GET path="/api/products/list" host=cheapandnice-backend.herokuapp.com
request_id=98822b44-b339-48ec-b33d-c7dd91e8a380 fwd="186.168.187.244" dyno=web.1 connect=1ms
service=30000ms status=503 bytes=0 protocol=http
I'm using Mongo Atlas
Ok so it turns out it's not a CORS problem. Heroku logs --tails shows this
2020-05-09T01:57:35.629379+00:00 app[web.1]: [db] Cannot read property 'split' of null
I put simple quotes when I configured my ENV variables in heroku
'mongodb+srv://...'
I removed the quotes and it works now
I have a simple MERN app developed and working locally. However I have "site can not be reached" after deploying to Heroku.
Here are my Heroku logs:
2019-09-12T00:33:00.665358+00:00 heroku[web.1]: Starting process with command `npm start`
2019-09-12T00:33:03.909328+00:00 app[web.1]:
2019-09-12T00:33:03.909347+00:00 app[web.1]: > myStreet#1.0.0 start /app
2019-09-12T00:33:03.909349+00:00 app[web.1]: > node server.js
2019-09-12T00:33:03.909351+00:00 app[web.1]:
2019-09-12T00:33:05.050233+00:00 heroku[web.1]: State changed from starting to up
2019-09-12T00:33:04.994283+00:00 app[web.1]: LISTENING ON PORT 3001
2019-09-12T00:33:05.082318+00:00 app[web.1]: (node:23) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2019-09-12T00:33:05.229315+00:00 app[web.1]: connected to the database
2019-09-12T00:33:12.960721+00:00 app[web.1]: GET / 404 4.000 ms - 139
2019-09-12T00:33:12.960048+00:00 heroku[router]: at=info method=GET path="/" host=dry-hamlet-33823.herokuapp.com request_id=d8a5cd47-50fa-428a-92d0-97ccba40db05 fwd="65.95.137.53" dyno=web.1 connect=2ms service=14ms status=404 bytes=415 protocol=https
What's the problem, and how can I fix it? I used the process.env.PORT to set the port.
============
Thanks for everyone's help,I solved the issue via watching this https://www.youtube.com/watch?v=e1LaekAnVIMo
LISTENING ON PORT 3001
This is almost certainly an error.
You don't get to pick your port on Heroku: it sets an environment variable PORT that you must use when starting your server. While it's possible that Heroku gave you port 3001 that seems unlikely.
This sample Node.js application gives an example of how to use the PORT environment variable with Express.
Heroku sets the PORT as an environment variable. So change the code accordingly.
const port = process.env.PORT || 3001;
app.listen(port, () => {
console.log('LISTENING ON PORT ' + port);
});
Here is the error:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
Analyzing the log, I noticed that every time I 'run' the app on Heroku it directs to a different port.
I have already encountered numerous examples of how to solve this, but using Express and not explicitly using AdonisJS (which I am finding very limited).
Another issue I have is the use of the domain for my application, should the be the same as the Heroku provides or localhost (127.0.0.1)?
My log:
2019-03-28T12:54:19.688098+00:00 app[web.1]: info: serving app on http://127.0.0.1:48470
2019-03-28T12:55:17.075091+00:00 heroku[web.1]: State changed from starting to crashed
2019-03-28T12:55:17.081028+00:00 heroku[web.1]: State changed from crashed to starting
2019-03-28T12:55:16.883066+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-03-28T12:55:16.883174+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-03-28T12:55:17.056876+00:00 heroku[web.1]: Process exited with status 137
2019-03-28T12:55:20.176409+00:00 heroku[web.1]: Starting process with command `ENV_SILENT=true npm start`
2019-03-28T12:55:22.553527+00:00 app[web.1]:
2019-03-28T12:55:22.553548+00:00 app[web.1]: > adonis-api-app#4.1.0 start /app
2019-03-28T12:55:22.553551+00:00 app[web.1]: > node server.js
2019-03-28T12:55:22.553552+00:00 app[web.1]:
2019-03-28T12:55:23.598805+00:00 app[web.1]: info: serving app on http://127.0.0.1:37943
2019-03-28T12:56:20.763929+00:00 heroku[web.1]: State changed from starting to crashed
2019-03-28T12:56:20.660053+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-03-28T12:56:20.660202+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-03-28T12:56:20.747895+00:00 heroku[web.1]: Process exited with status 137
2019-03-28T12:56:23.940320+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=***** protocol=https
2019-03-28T13:21:40.085858+00:00 heroku[web.1]: State changed from crashed to starting
2019-03-28T13:21:43.920685+00:00 heroku[web.1]: Starting process with command `ENV_SILENT=true npm start`
2019-03-28T13:21:46.419408+00:00 app[web.1]:
2019-03-28T13:21:46.419429+00:00 app[web.1]: > adonis-api-app#4.1.0 start /app
2019-03-28T13:21:46.419431+00:00 app[web.1]: > node server.js
2019-03-28T13:21:46.419433+00:00 app[web.1]:
2019-03-28T13:21:47.899057+00:00 app[web.1]: info: serving app on http://127.0.0.1:51104
My .env file:
HOST=127.0.0.1
PORT=8080
NODE_ENV=development
APP_NAME=AdonisJs
APP_URL=https://${HOST}:${PORT}
APP_KEY=*******
How to prevent the port from being changed?
There are a few things going on here.
Configuration from the environment
There are two main benefits to configuring your application from the environment:
It makes configuration environment-specific, e.g. so you can use different databases, mail servers, etc. in development from the ones you use in production
It lets you keep sensitive values like API keys and passwords out of your codebase
Including your .env file in your repository negates both of these benefits. It's fine to use one in development, and it can be a convenient way to set environment variables, but it shouldn't be committed to your repository or used in Heroku.
Heroku natively supports configuration from the environment. You can set variables in the web UI or via heroku:config on the command line. This is where your environment variables should go in production.
I strongly urge you to remove your .env file from your repository with
git rm --cached .env
add it to your .gitignore, and use Heroku's native environment-based configuration instead. You should also invalidate any API keys or passwords that are contained in that file and generate new ones.
For what it's worth, the AdonisJS documentation agrees with this approach:
The .env file should never be committed to your source control or shared with other people.
Different ports
This is entirely expected:
On Heroku, apps are completely self-contained and do not rely on runtime injection of a webserver into the execution environment to create a web-facing service. Each web process simply binds to a port, and listens for requests coming in on that port. The port to bind to is assigned by Heroku as the PORT environment variable.
Heroku tells you which port to bind to via the PORT environment variable, and you must use it. But this isn't the port that will be visible externally; the standard HTTP ports will be routed to your application automatically.
IP addresses
Your application should listen on all IP addresses. If you're using Express, I think that means you don't provide an IP address in your .listen() call. You should only provide the port there, and that port should come from the PORT environment variable.
It is the first time I do something like this. Any pointers or tips to the right direction will greatly help.
I am trying to run this Bitgo's service on Heroku. I followed Heroku's tutorial and pushed the app.
This app is not a web app. It is a service receiving requests. I am wondering how I will run it to receive this requests on Heroku.
I created a "Procfile" and wrote the following line in it:
web: ./bin/bitgo-express
Then when I check the logs (without doing or trying anything at all) I get the following errors and logs:
2016-06-16T08:22:35.353721+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-16T08:22:37.366281+00:00 heroku[web.1]: Starting process with command `./bin/bitgo-express`
2016-06-16T08:22:40.433443+00:00 app[web.1]: BitGo-Express running
2016-06-16T08:22:40.434385+00:00 app[web.1]: Environment: test
2016-06-16T08:22:40.434540+00:00 app[web.1]: Base URI: http://localhost:3080
2016-06-16T08:23:37.991458+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-06-16T08:23:37.991458+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-06-16T08:23:38.795553+00:00 heroku[web.1]: Process exited with status 137
2016-06-16T08:23:38.810670+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-16T08:23:41.439218+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=example.com request_id=a42a1654-2593-499c-81fa-a585464b2805 fwd="109.110.240.32" dyno= connect= service= status=503 bytes=
2016-06-16T08:23:42.964194+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=example.com request_id=008620c3-b40f-43c1-add3-e3f8b785d5c5 fwd="109.110.240.32" dyno= connect= service= status=503 bytes=
A note. When I run this service locally it opens a website that redirects to a bitgo's website but I am also able to execute commands and work with the service.
I googled the error and tried this solution which proposes to change the listening port but I was still getting the same behaviour. Just to clarify on the bitgo app I changed all 3080 ports to 5000 that Heroku uses.
I then tried this solution which proposes to change the "web" process to "worker" but I was getting errors that they seem to be generated because of the reason that the service was not structured as a worker process (maybe, that is what I think) but web process.
And lastly, I changed the procfile's text to web: ./bin/bitgo-express -p 3080 so it runs at the 3080 port but I was still getting the same error
Edit:
I have web: ./bin/bitgo-express -p 5000 -b 0.0.0.0 in my procfile.
Again, same result. Here are the logs:
2016-06-20T06:17:36.753762+00:00 heroku[web.1]: Starting process with command `./bin/bitgo-express -p 5000 -b 0.0.0.0`
2016-06-20T06:17:39.333304+00:00 app[web.1]: BitGo-Express running
2016-06-20T06:17:39.334368+00:00 app[web.1]: Environment: test
2016-06-20T06:17:39.334384+00:00 app[web.1]: Base URI: http://0.0.0.0:5000
2016-06-20T06:18:36.768622+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-06-20T06:18:36.768550+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
Make sure you specify -b or --bind as 0.0.0.0 in your Profile. Otherwise, it will try to bind to localhost, which cannot be reached from Heroku's routing tier.
You should use the $PORT environment variable provided by Heroku on your Procfile, i.e rails application: web: bin/rails server -p $PORT -e $RAILS_ENV
For BitGo you can configure like that: web: ./bin/bitgo-express -p $PORT -b 0.0.0.0