Problem with heroku [solved]

I got my first microservice working. Well, it works locally. When I put it on Heroku, it doesn’t work anymore.

I get an error message: GET https://powerful-wildwood-24036.herokuapp.com/favicon.ico 503 (Service Unavailable)
Not sure what that is about.

From what I understand, aside from the difference in the port (I use 3000 for local, process.env.PORT for Heroku), if it works locally it should work on heroku as well, right? Or did I forget something else?

Can you show your code for the app you deployed?

You can sometimes diagnose problems by running heroku logs -t in a separate terminal window and then trying to launch the app again.

The -t flag adds live logging on the ‘tail’ of your logs, so you can see errors as they happen.

If you find anything interesting or confusing in the logs, post them here :slight_smile:

The repository: the repository is: https://github.com/Marie000/FCC-timestamp-microservice
The main file is this:

var express = require(‘express’);
var app = express();
var PORT = process.env.PORT || 3000;

app.use(express.static(__dirname + “/public”));

app.get(’/:date’,function(req,res){
var input = decodeURI(req.params.date);
var isNumber = /^\d+$/.test(input);
var unix, string;
if(isNumber){
var t = new Date(parseInt(input));
string = t.toUTCString();
unix = input;
} else {
unix = Date.parse(input) || “null”;
string= Date.parse(input) ? input : “null”;
}

var output = {
string: string,
unix:unix,
};

res.json(output)
});

app.listen(PORT,function(){
console.log('server successfully started on port '+PORT);
});

THANK YOU JacksonBates!
I did the heroku logs -t and got an error saying I was missing a start script.
I added one, and now all is working.

:smile:

One back-end project done, just 9 more to go!

1 Like

Hi Everyone

I deployed my app but i got this problem : favicon.ico:1 GET https://movio-deploy-app.herokuapp.com/favicon.ico 503 (Service Unavailable)

My file package.json :

{
“name”: “example2”,
“version”: “0.0.0”,
“license”: “MIT”,
“scripts”: {
“ng”: “ng”,
“start”: “node server.js”,
“build”: “ng build --prod”,
“test”: “ng test”,
“lint”: “ng lint”,
“e2e”: “ng e2e”,
“postinstall”: “ng build --aot -prod”
},
“private”: true,
“dependencies”: {
"@angular/animations": “^5.2.0”,
"@angular/cli": “^1.7.3”,
"@angular/common": “^5.2.0”,
"@angular/compiler": “^5.2.0”,
"@angular/compiler-cli": “^5.2.9”,
"@angular/core": “^5.2.0”,
"@angular/forms": “^5.2.0”,
"@angular/http": “^5.2.0”,
"@angular/platform-browser": “^5.2.0”,
"@angular/platform-browser-dynamic": “^5.2.0”,
"@angular/router": “^5.2.0”,
“core-js”: “^2.4.1”,
“express”: “^4.16.3”,
“rxjs”: “^5.5.6”,
“typescript”: “~2.5.3”,
“zone.js”: “^0.8.19”
},
“devDependencies”: {
"@angular/cli": “^1.7.3”,
"@angular/compiler-cli": “^5.2.9”,
"@angular/language-service": “^5.2.0”,
"@types/jasmine": “~2.8.3”,
"@types/jasminewd2": “~2.0.2”,
"@types/node": “~6.0.60”,
“codelyzer”: “^4.0.1”,
“enhanced-resolve”: “^3.3.0”,
“jasmine-core”: “~2.8.0”,
“jasmine-spec-reporter”: “~4.2.1”,
“karma”: “~2.0.0”,
“karma-chrome-launcher”: “~2.2.0”,
“karma-coverage-istanbul-reporter”: “^1.2.1”,
“karma-jasmine”: “~1.1.0”,
“karma-jasmine-html-reporter”: “^0.2.2”,
“protractor”: “~5.1.2”,
“ts-node”: “~4.1.0”,
“tslint”: “~5.9.1”,
“typescript”: “~2.5.3”
},
“engines”: {
“node”: “8.9.1”,
“npm”: “5.5.1”
}
}

And log in heroku, when I press this command heroku logs indicate that not exits.

2018-03-16T10:01:09.177701+00:00 heroku[run.7233]: Awaiting client
2018-03-16T10:01:09.219456+00:00 heroku[run.7233]: Starting process with command heroku logs
2018-03-16T10:01:09.362264+00:00 heroku[run.7233]: State changed from starting to up
2018-03-16T10:01:13.557037+00:00 heroku[run.7233]: State changed from up to complete
2018-03-16T10:01:13.542584+00:00 heroku[run.7233]: Process exited with status 127
2018-03-16T10:01:49.853376+00:00 app[api]: Starting process with command heroku run by user lsanchezalzamora@gmail.com
2018-03-16T10:01:59.574184+00:00 heroku[run.1518]: Awaiting client
2018-03-16T10:01:59.600959+00:00 heroku[run.1518]: Starting process with command heroku run
2018-03-16T10:01:59.809450+00:00 heroku[run.1518]: State changed from starting to up
2018-03-16T10:02:04.135784+00:00 heroku[run.1518]: State changed from up to complete
2018-03-16T10:02:03.994428+00:00 heroku[run.1518]: Process exited with status 127

Thanks in advance.

Luis

I had the wrong URI link to my DB in Heroku config vars (under settings).

I’m getting the same issue:

Alans-iMac:AAH-react-portfolio hvaandres$ heroku logs --tail
2020-01-16T06:24:21.887929+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/" host=ah-react-portfolio.herokuapp.com request_id=74e6fd32-0705-43a1-a8ad-ff8bede2eb3e fwd=“65.181.49.17” dyno= connect= service= status=503 bytes= protocol=https
2020-01-16T06:24:22.685984+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/favicon.ico" host=ah-react-portfolio.herokuapp.com request_id=8706ffec-8189-4eac-bca8-4a09702bca2e fwd=“65.181.49.17” dyno= connect= service= status=503 bytes= protocol=https

@hvaandres, were you able to solve your problem?

Yes, these issues were related to the dependencies that I have installed since I have to make an update from all of these dependencies to make sure Heroku will take my files.