node http server not listening - node.js

For some reason my express node.js server won't start anymore. Usually I just run the npm start command in my application folder and the server will start listening. now it is stuck at > node ./bin/www.
> myapp#0.0.0 start C:\Users\...\first-app
> node ./bin/www
I did not change anything significant, just restarted the server and it did not work anymore. This already happened before and I reinstalled express and then it would work again. I just cant reinstall express all the time.
Also changed ports, same result.

Related

Node express server always shuts down

I have a angular app running in a universal express server.
I start the server with
nohup node server.js &
exit
The server runs fine, but after a while 5 to 30 Minutes it stops with nothing in the nohup logs.
Same happens with forever or pm2, after a while the server is gone without any hint for the error.
Any ideas how to debug, this is on a hosting environment.
Thanks

Ember Server: "Port 4200 is already in use", when no process runs on 4200

When running my ember application with ember serve -e local I get:
Port 4200 is already in use.
Which is weird because no application is running on 4200. I tried to open a dummy HTTP server on 4200 with http-server and it works just fine. It also works when I specify the port via a command line flag ember serve --port 4200.
Some things I've tried:
Restarted my computer.
Removed the node_modules.
Remove the ember tmp directory.
Disabled my firewall.
Tried with disabled wi-fi.
Any thoughts?
I'm running on masOS High Sierra 10.13.6 with the following versions:
node: 8.11.3
ember-cli: 2.18.2
npm: 5.6.0 (also tried with 6.3.0)
Also useful to know:
I have other ember applications running on my computer just fine.
I started to have this problem only recently.
In the past, macOS would keep asking me about authorizing incoming traffic whenever an app was opened, but now it stopped asking me.
I had this issue and tracked it down to using a string vs. integer for port in .ember-cli.
// .ember-cli
{
"port": 8080, // works
"port": "8080", // throws the error mentioned above
}
Not sure if this is the cause for others with this error. As mentioned, first thing is to make sure nothing else is actually running on that port. But OP had already checked that, and so had I.
After further investigation, it seems that the problem is not coming from macOS, but from something messed up in the dependencies causing ember-cli to fail...
It's not quite clear what is causing this, and I will try to post any additional information here, but for now if you happen to encounter this problem, just pass the port value directly to ember-cli like so:
ember serve --port 4200

My Express Node.JS App times out

I have installed Node.js on my web server plus the dependencies for Express. When I run the command npm start and go to my web site's address using the port 3000 (which I believe the app is set to by default?), it just keeps loading and never loads. Any tipps please on how to fix this?
Try this $ PORT=8080 node app.js. Here app.js is your server config file. I suspect some background servers are running in that port 3000.

Application generated with JHipster 4 returning blank page on 8080, but not on 9000

I've create an application with JHipster v4. When I make a request on port 8080 it is returning a blank page. If I use yarn start, and I make a request to 9000 port, it is answering correctly.
Any idea?
I had the same issue with JHipster application bringing up the blank page on port 8080 when ran with ./mvnw in dev mode. I was able to resolve this by running:
yarn install && yarn webpack:build
After it finishes, the application shows normally in dev mode on port 8080.
I had the same issue where on port 8080, it was returning nothing and on 9000 it gave correct page , after
yarn install && yarn webpack:build
I get correct page on both, I noticed that if I only run .mvnw, the application runs fine and I do not need to run "yarn start"
By default, yarn listens on port 9000 (webpack + browser sync) to hot reload frontend code and contents, maven or gradle listens on port 8080 to hot reload server code. You must run both in dev.
If you start making changes to the client side code without having yarn start running, nothing will be reflected as the changes are not compiled so you need to either run yarn webpack:build manually after changes or have yarn start running.
It's written in the README.md of the project you generated and is documented on JHipster web site.
You should run npm install then mvnw, and it will run good.
For me (using npm for the front-end), just running npm start before mvnw makes the front-end available on 8080.
On the other hand, running npm start after mvnw will bring a blank page on 8080.

Debugging node.js apps in WebStorm 7

I am having a strange issue debugging node.js apps in WebStorm 7.
The first time I start the debugger I get the application running:
/usr/bin/node --debug-brk=34041 app.js
debugger listening on port 34041
Current Environment: development
Express server listening on port 3000
But, after the first time (or if I restart the debugger), I get the debugger running but not the app, like below:
/usr/bin/node --debug-brk=42140 app.js
debugger listening on port 42140
or
/usr/bin/node --debug-brk=51341 app.js
debugger listening on port 51341
I need to restart the WebStorm itself in order to debug the app again.
Is it a bug in WebStorm?
Is it a bug in Node.js?
Is there a way to make it work properly?
After contacting the support, I found that it was a bug in the WebStorm, already fixed in version 7.0.1.

Resources