Local http server has stopped running - javascript

I installed the NPM package and the http server in the "server" folder. Everything worked perfectly, but then suddenly the server stopped running.
When I try to start the local http server I see this error message in the terminal (console)

You probably have anlther application running on port 8080. Try navigating to localhost:8080 to figure out what it is and close the application.
It could even be another instance of node.

Related

ExpressJS webseite works local but returns 403 Forbidden online

I'm trying to get this example ExpressJS app running on my server.
Offline (on localhost) it is working correctly after running npm start.
I uploaded all files, installed everything through npm install, started the nodemon through SSH npm startand got the App Running response.
If I try now to open the URL of the website it returns 403 Forbidden.
What do I need to change to make it work?
(It's my first time working with ExpressJS - maybe it's just a noob issue. Could this be a HOST or PORT issue?)

Node.js WebStorm remote debugging not working (without SSH tunnel)

I'm trying to debug on a live server running a Node.js webserver (Express, TypeScript).
I run the node server with NODE_ENV=development node --inspect=9229 --inspect-brk build/start.js, and it says it's waiting and listening (Debugger listening on ws://127.0.0.1:9229/a61485f2-aef8-4719-901d-4d5ad9d1e6cd).
I set up an SSH tunnel (using this method: https://gist.github.com/pajtai/081e0371e7366c79c0b9), and I set up an "Attach to Node.js/Chrome" debug configuration, with Host: localhost and Port: 9229. Then when I hit the debug button, it connects through the SSH tunnel, and the node.js process runs just fine, stopping and debugging at all my breakpoints.
However, when I don't set up the SSH tunnel, start the node server the same way, and set up an "Attach to Node.js/Chrome" profile with the host as the URL or IP of the server, WebStorm can never connect. There is a little red bubble over the "5: Debug" icon at the bottom saying it can't connect, and sometimes it says "Closed Explicitly". I have opened up port 9229 in the firewall settings for the server (I've tried TCP and UDP).
What am I doing wrong? Please help, anyone!
I'm using Mac OS X 10.15.3 and WebStorm 2019.3.1.
Node binds to localhost by default and thus can't be accessed from outside unless you set up the port forwarding (via ssh tunneling, for example).
You can try changing the command to node --inspect-brk=0.0.0.0:9229 build/start.js - does it help?
Note that Node.js discourages using remote debugging in this way: https://nodejs.org/en/docs/guides/debugging-getting-started/#enabling-remote-debugging-scenarios. Using SSH tunneling is recommended

How to do a reverse proxy with node.js for a shiny app

EDIT
I think the problem might be that the WebSocket connection does not go through the proxy node.js. How to authorize the connection of the WebSocket?
I have a web app hosted on a nodeJS server. On the same vm I also have a shiny serveur hosting an app. I use node to redirect traffic to port 3838 (shiny) when a somes URL are requested.
I use this code on node :
app.use('/the-shiny-app', proxy({target: 'http://localhost:3838', changeOrigin: true}));
With this setting everything works fine on the shiny app when I go on mydomain/the-shiny-app/* except when I try to run code in a code box.
When I try to run code I get this error on the chrome console :
Connection closed. Info: {"type":"close","code":4503,"reason":"The application unexpectedly exited","wasClean":true}
An example of what I mean by code box :
if I do not use node.js and I redirect the traffic (on OS level) from port 80 directly to 3838 everything works fine.
sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-ports 3838
I do not know exactly what kind of exchange is made between the browser and the shiny server when we run code, but maybe the protocol used is blocked by node.js.
I found the problem. As Antony Gibbs said you need to setup a WebSocket upgrade. I'm using http-proxy-middleware you cans find the doc here : https://github.com/chimurai/http-proxy-middleware

Meteor deployed on server, but browser says site can't be reached

So I've deployed my meteor app, and have it up and running on an instance.
I've used the following environment variables:
MONGO_URL='mongodb://localhost:27017/meteor'
ROOT_URL='http://<my static ip>'
PORT=3000
And I run the program using the following command:
node bundle/main.js
It prints my "Meteor is starting up" that is printed using the console.log command, and then doesn't error out, but when I navigate to http://< my static ip >:3000 in a browser, I get an ERR_CONNECTION_REFUSED result.
My open mongod terminal says it's connecting fine to the MongoDB database.
Does anyone have any ideas on how to start debugging this issue?
Thanks.
In server you don't need to run meteor application on port 3000. You can run it on port 80 if the port is not being used by any other program.
If you are using port 80 make sure port 80 is opened by the network security rules.
If you are using port 3000 or any other port you will have to make sure that port is opened by the network security rules as above. Additionally you will have to mention the IP in your url, like http://<your_ip>:<port>

How to run a webapp in browser using localhost?

I have a program in node.js. I ran the code using "node main.js". It starts listening. When I try to open the link, "https://localhost:8080" it displays, "It works !
If you're seeing this page via a web browser,"
which is usually popped up after tomcat installation. how can i fix it and run my code?
You probably have a tomcat server running on the same port. Shut it down and run the node.js server only

Categories