how can i post / get data from nodejs server using another computer ?
so i'm connecting too computers using ethernet cable ,and i was able to open the website (react ) but
when i try to post or get data i get this error ( from the one who's not running the server on )
POST http://localhost:8080 net::ERR_CONNECTION_REFUSED
the too computer are running on the same network
i replaced localhost with the local IP address but still same error
i also added my local ip adresse to the app.listen
app.listen(PORT,'169.254.xxxx', () => {
console.log(`Server is running on port ${PORT}.`); //PORT = 8080
});
but still getting same problem
Ok I am making website and want to use mongo, express, etc. I setup a server using fedora server ISO. The problem is getting node working. I have followed several tutorials, and its all the same. Nothing works. So I have to be doing something wrong. Trying to get the simplest thing to display on screen.
I think the server is running httpd server, whatever fedora has built in. I get the default fedora server page when going to the url. So the server is running and working, just hasn't been configured. When running node on the server do I have to use httpd-node? Or can it be http, etc.
Here is my app.js
const express = require('express')
const app = express()
app.get('/', function (req, res) {
res.send('Hello World!')
})
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
})
And then I have a basic index.html that should be rendered just saying test.
I ssh into the server and run node start, it runs and the console logs the message like it should. But if I go to the address 192.168.1.5, or the domain that points to the server, I get nothing, just a blank page.
If someone can help me get this working, I can actually get to work coding out the application. Any help would be appreciated.
I think you make a confusion. When you build an Express application, you do not need another server at all.
When you start your app with:
app.listen(3000, function () {})
Express returns an http.Server object listening to port 3000.
When you navigate to your local adress on port 3000, you will see your "hello world" message.
It is possible that httpd service is already running in your Fedora environnement on default port 80 (the default port for http, the one your reach when you go to your local adress) but this is an Apache server and you do not need it to run your Nodejs app.
To build a Nodejs server, you can also use httpd-node package, but this is redundant as you're using Express framework.
If you need to serve a simple html file, a method I like for its simplicity is to use ejs template engine, something like this.
res.send('Hello World!') - this is your problem! Why?
How you receive this answer on client side?
Solution: use res.render(..) - for rendering from server or use AJAX on client side for receive this text!
P.S: render page and you don't see blank page anymore! Or use client-server conversation logic with your server through AJAX.
Try 192.168.1.5:3000
If I wrong: show your full project setup...
Test your app with curl (https://curl.haxx.se)! Check connection establishment, and show results here!
I have just started google app engine with nodejs. I have created a local project that works fine on my machine. And If I hit
http://localhost:7000/services/user/getuser
it returns a json object.
I have deployed the same project on google app engine using
gcloud app deploy
Now when I hit
http://help-coin.appspot.com/services/user/getuser
it is showing
Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.
I have checked the logs on server
Load controllers from path '/app/app/services' non recursive.
--------make-runnable-output--------
undefined
------------------------------------
Up and running on port 7000
Loading controller 'UserService.js'.
No error on the server side. What is this issue? Am I missing something?
Here is the project that I have deployed https://github.com/ermarkar/nodejs-typescript-sample
Your app must listen to 8080, not 7000 or any else port.
See this.
Listening to port 8080
The App Engine front end will route incoming requests to the appropriate module on port 8080. You must be sure that your application code is listening on 8080.
Hello I'm trying to deploy an express app that uses Socket.io for communication with the node server it's hosted on.
First problem : the server couldn't find the socket.io node module
somehow... even though it gets resolved on localhost.
We then switched to loading the socket.io client side through the socket.io cdn.
But we are getting this being spammed in the console :
Failed to load resource: the server responded with a status of 404
(Not Found)
https://pictionar-e.herokuapp.com/socket.io/?EIO=3&transport=polling&t=Lbg7iEM
From this error is looks like socket.io is trying to communicate over polling ? But I don't get why.. heroku supports websockets. Could https cause things not to work anymore?
Server side we've got the socketio/express server setup like this :
app=express();
server=require("http").Server(app);
server.listen(port,function () {
console.log("Server started at port: "+port);
});
io=require("socket.io")(server);
On localhost everything works fine but when on heroku the socket.io doesn't work, while the express server does its thing perfectly fine...
Note: we are using the port that gets assigned automatically by the heroku environment
I am new to node.js, so hopefully I'm missing something obvious.
I have a Windows Azure VM running Windows Server 2012. It has IIS installed and simple, static sites returning static HTML works fine.
I have installed node.js on this server (via Chocolatey). I've created a simple Hello World node.js application (test.js):
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.send('Hello World');
});
app.listen(80);
I fire this up on the server via: node test.js
It works fine on the server when I browse via http://localhost/test.js
It is unreachable from my client machine's browser via http://<servername>/test.js
I have:
created an endpoint on my VM to allow port 80 via TCP;
created a firewall rule on my VM to allow port 80 traffic
a web site on IIS for port 80 and it's running
When I change the above code to listen on a different port (e.g. 2368) and make the appropriate endpoint and firewall rules, everything works great both on the client and the server. I have no problem accessing the site.
What am I missing with port 80 here? Why can't I access my test file via port 80, but I can access it via a different port?
Hopefully it's something obvious. Thank you in advance.