Heroku only works if my local host server is working - node.js

my heroku deployment only works when my local host is running.
I havent checked if it works on other computers - but it doesnt work on my phone for example.
So far I was only able to run it on my PC - it works on both localhost and the site deployed to Heroku (link here to it).
When I had the server down ( node index.js wasnt running ), neither heroku nor the localhost servers were working.
Then when I turned it back on - both localhost and heroku serves started working. 👍
What could be causing this ?

Related

Heroku fails to host my Node.js App , I just see "Cannot Get /"

I have looked at similar questions and not been able to solve this problem with what I found. I initially followed a YouTube tutorial on how to deploy a Node.js App to Heroku. After trying and failing, I began troubleshooting and could not fix the problem.
I then followed the instructions on Heroku's website for deploying a Node.js application here: https://devcenter.heroku.com/articles/deploying-nodejs and I found I seem to have done all the steps correctly. I was just missing the node version in the package.json which I have now added.
Here is how I have connected my Node.js app:
image of Heroku application dashboard
And here is the connected Github repo: https://github.com/AmeenIzhac/food-and-flow-backend
You can see in the repo that my port is specified correctly:
const port = process.env.PORT || 4000;
I then tried running the app locally on the command line with:
heroku local web
and this worked as you can see my application running on port 5000:
App running locally on port 5000
However when I press "Open app" in Heroku, I just see this:
Heroku hosted app fails to get /
I feel like I have done everything correctly but it doesn't seem to work. Any help to get it working would be much appreciated.
You need a procfile. What is the heroku error in heroku logs --tail?

node.js ENOTFOUND on windows despite working on mac

After having deployed a small project on mac I tried to get it running on another PC, windows this time (only have access to that one atm).
Using the same code, node.js version etc. I run into a problem.
When making a call to my mamp apache from my vue project (vue has host 8080, the apache server 80) I get greeted with a error 500 ENOTFOUND.
I configured the proxy in my vue.config which works on mac just fine. Strange thing on windows is I can change the localhost port (or 127.0.0.1) to whatever I want, it will always get resolved to port 80.
Anything I am overlooking here?

The Nginx server returns error 502 for some directories (Express Application)

I'm running an express application using nginx web server on Ubuntu. everything works fine but today when I added two more directories using app.get method and re-deploy my app, the new directories won't work and it returns 502 Bad Gateway errors (old directoriesn are working fine). Restarting pm2, nginx and the server itself didn't help. What should I do?
After a couple of hours I realized that the problem was in my code and not relevant to nginx. But because of pm2 the server would not crash to help me find that out.
running normal run command:
node server.js
revealed the mistake

after deploy mean stack project on heroku it work only when local server running if close local server

after deploy mean stack on heroku in work good if local server running but if i close local server get error "POST http://localhost:4000/api/newcontact net::ERR_CONNECTION_REFUSED " and how it work with localhost after deploying
In your code, you might be using http://localhost:4000 in the services. Change it to the URL where your API is actually hosted.

Nodejs app working on localhost but crashes on heroku

My nodejs app is working on localhost but when deployed with heroku, it crashes showing me one new module or the other that it cannot find. What do I do?

Resources