I'm currently trying to get my javascript+webpack app to deploy on Heroku.
Github link of the app here.
It works fine locally, but I can't manage to deploy it on Heroku. I get an error message like: App boot timeout. See screenshot below:
Screenshot 1:
Screenshot 2:
Does anyone have an idea of how I can fix this?
ps: I tried Netlify, managed to have the app displayed but API calls didn't work because my API URL starting with http instead of https, but no way around that the API selected for this project doesn't on https :-( so that's why I'm trying to get this one to work on Heroku.
This is happening because your express code is binding to port 8081, while heroku likes to pass in it's own port when deploying express apps. That's why your error message is saying Web process failed to bind to $PORT within 60 seconds of launch. To fix this you need to pass in your port as a variable and bind to it.
server.js
const app = require("./index.js");
app.set('port', process.env.PORT || 8081);
app.listen(app.get('port'), function () {
console.log(`running on localhost: `, server.address().port);
});
Minimal code example here.
Related
There was a solution available on github of adding the variable i did that, what ever i put port number it says already in use, follow is the error on deploy log..
listening on port 9586
Port 9586 is already in use
[nodemon] app crashed - waiting for file changes before starting...
Following is the error when i open the deployed link
Application Error
Is your app correctly listening on $PORT?
View the deployment below to check for errors
this is the link of deployed repo https://rehub-backend.up.railway.app/ ,
Please do assist if u have any idea
In place of
app.listen(PORT);
use
app.listen(process.env.PORT);
I have a create-my-react bootstrapped application that is essentially a website that uses some FETCH API calls to a external API and it is deployed and works fine.
However, I added my own Nodejs backend, by creating a server and using using express for the routes/middleware. Everything works fine locally. I can hit my internal API endpoints (localhost:3000/myapiurlhere) and it performs an action on a database.
I have to run npm start to start up the create-my-react-app locally and then manually run the node server by node src/server.js then my internal API works.
The Azure Web App service is basically a preconfigured server with the Node RUNTIME on it, and it only seems to give you access to the D:\home\site\wwwroot folder (Windows server).
Do I need to find a way to run node server.js command on the server to start my node backend, or should it be running automatically? Also, I'm using create-my-react-app and npm run build , so it creates a build folder with a nested static folder.
I have started up REST APIs on Java on my Linux Ubuntu servers before but never on an App Service like Azure. How can I achieve what I'm trying to do?
Here is my server.js file:
const http = require('http');
const app = require('./app');
const port = process.env.PORT || 3001;
const server = http.createServer(app);
server.listen(port);
You dont have to do anything special, Have you followed this page on how to deploy basic nodejs app on Azure AppService?
One additional thing you need to do is that pass the Node version on appsettings of the appservice.
WEBSITE_NODE_DEFAULT_VERSION for the setting key.
I'm developing a node.js application on AWS Cloud9 environment.I'm using express to run a local server.I have installed express version 4.17.1 and using node version 10.6.3.I want to run or preview my application on port 8081 or 8082 but it isn't previewing. Url i'm pasting is https://blablabla.vfs.cloud9.us-east-1.amazonaws.com:8081/ and it shows The web page at https://blablabla.vfs.cloud9.us-east-1.amazonaws.com:8081/ might be temporarily down or it may have moved permanently to a new web address.. Note- In past it used to run on different ports like 8081,8082.Take a look at this code which i'm using.
var express=require('express');
var app=express();
app.get("/",function(req,res){
res.send("cfg");
});
app.listen(8081,process.env.IP);
It is running on default port 8080 ie if we replace 8081 in above code with process.env.PORT, it shows the ouput "cfg" on browser.I know it's a easy one but please check this issue once, maybe there is some problem with my ec2 instance.
I provided an api to my react app, it was working fine, but suddenly it stopped working.
in my client (React app) package.json
"proxy": "http://localhost:7000"
now it tell me this error message:
Could not proxy request /api/users/signup from localhost:3000 to http://localhost:7000.
thanks in advance.
Maybe you created a socket and didn't free the port afterwards ? This may happen if your app crashes. When you launch it again, the port may be occupied and unavailable, it happened to me a few times.
I'm trying to set up a simple "Hello world" node.js app.
I've created the following index.js file:
var app = require("express")();
var http = require("http").Server(app);
app.get("/", function(req, res){
res.send("<h1>Hello worlddddd</h1>");
});
http.listen(8080, function(){
console.log("listening on *:8080");
});
When I open up my local console, and perform node index.js, I get the message "listening on *:8080", as expected. I point my browser to localhost:8080, and I see the HTML page saying "Hello worlddd", as desired.
Now, I'm trying to do the same on my Virtual Private Server, so I can access the same app from different computers, but all I get is connection timeouts. I've followed these steps:
Install node.js on my VPS
Install express via npm install --save express#4.10.2
Upload my index.js file to the var/www/html folder on my server with IP 192.123.123.12 (an example, this isn't my real IP).
Access the server via PuTTY, and run node index.js, where I get "listening on *:8080", so I know node.js is working.
Now I point my browser to http://192.123.123.12:8080 and after about 20 seconds, I get the browser error: "The connection has timed out".
I've tried listening to port :80 instead, but I get the error that this port is already in use.
Does anybody know what I'm doing wrong? Am I using the wrong port? Am I pointing to the wrong URL? Do I need to modify my server preferences? (running Apache on CentOS). I've only found dozens of tutorials that teach you how to run a node.js app on your local computer(pointing the browser at localhost:8080), but I need it to run on my remote server so multiple computers can access the same app.
The issue is that your current filters (iptables) block traffic unless you explicitly allow it.
You just need to open port TCP 8080 inbound, and you should be able to reach your node.js server!