I wrote and ran a node.js program (eg: hello.js) on my linux server with IP Address 62.x.x.x with basic content:
var http = require('http');
http.createServer(
function(req,res){
res.writeHead(200, {'content-type':'Text plain'});
res.end('Hello ');
}
).listen(8000)
I tried to test it on the server with curl command: curl http: //127.0.0.1:8000
I got the expected result: hello on screen.
But when i tried it on my client machince with a browser client (IE, Firefox,...) http://62.x.x.x:8000 the webbrowser can not load this page and can not return my result.
I don't know what does this error mean?
The problem is that the firewall is stopping the page from loading. You need to configure your firewall to allow outbound traffic on port 8000
Try listeting to your external interface, like
).listen(8000, "62.x.x.x")
Related
When I run my NodeJS server in remote server with script "next" for example, it compiles successful and get "Running in localhost:3000" but when I try to enter to ip:3000 didn't get response from server.
What I should do?
Ubuntu server.
The server respond correctly without :3000
Have you tried to open the ports on your server for port 3000? :)
I'm on Ubuntu so this may be different on your system, but i think this should work for you.
ufw allow 3000
If you want to access remotely you cannot listen your server using localhost
Try to listen server in 0.0.0.0
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(3000, "0.0.0.0");
Debugging this might follow a path on these lines:
Verify the server is actually running on that machine. Try to connect to it locally from another shell on that that remote/server machine (use curl if the machine is headless). If it's not running locally, you clearly won't be able to connect remotely.
Assuming the service is actually running, determine if you have the right IP address for the remote machine. Running something like ifconfig (ipconfig on windows I think?) will tell you this.
Determine if you can reach the machine at all over the network. You might try to send it a ping, or connect to another service you know it's offering. If you can't reach it, is it running a firewall that's preventing you or is there address translation going on somewhere?
I am hosting a meteor app on an Ubunu Linux machine. The app is listening on port 3000. If I use a webserver, like NginX and forwards the HTTP requests from port 80 to 3000 I can browse to the server from the outside and see reach the app. However, when I try to access the app directly at port 3000, i.e. browse http://myhost:3000 it just tries to connect and nothing happens.
I have made sure that all firewalls are down and that the app is listening on all interfaces, i.e. 0.0.0.0:3000, so that is not the issue.
To verify that port was actually reachable, I created a simple node js webserver:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('Hello World!');
res.end();
}).listen(3000);
Now browsing to the the sever, I can see "Hello World!". So obviously this works so why I can not reach meteor has nothing to do with firewalls or unopened ports.
Thus it seems that there is something strange when trying to access a meteor app directly at port 3000. But why? I use the following environment variables:
export MONGO_URL=mongodb://localhost:27017/meteor
export HOST=myhost
export PORT=3000
export ROOT_URL=http://myhost
So what am I missing? Ports are open and I can see that the node process instance is listening on port 3000 when I run netstat -tulpan
I was using the force-ssl meteor package which makes a redirect back to the ROOT_URL without port number. So solution is to remove the package to make it work with a custom port.
I was discussing the solution on the meteor forum where I got the solution:
https://forums.meteor.com/t/can-not-access-meteor-app-without-passing-through-nginx-server/40739/11
I try using server side node.js and write a simple -general- javascript code for http request
var sys = require("sys"),
http = require("http");
http.createServer(function(request, response) {
response.sendHeader(200, {"Content-Type": "text/html"});
response.write("Hello World!");
response.close();
}).listen(1337);
sys.puts("Server running 8080");
when i execute on server it's work and give me out put "Server running 8080" string.
But couldnt connect to host when i check on browser.
(i try this http://myserverip:1337)
I open 1337 port but still same
Same thing on Linux. Check your network connectivity. If you are on Amazon, check your security groups. It has be something that is blocking that port.
In hostgator I have a VPS running centOS. I installed NodeJS and screen.
I added the following code to a file named index.js:
//1
var http = require('http');
//2
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<html><body><h1>Hello World</h1></body></html>');
}).listen(3000);
console.log('Server running on port 3000.');
On 'screen:1' I run the following command:
node index.js
It gives me the console output stating 'Server running on port 3000.'
I switch to 'screen:0' and run the following command:
curl localhost:3000
and I get the following response:
<html><body><h1>Hello World</h1></body></html>
Yet, when I try my server's IP address (substitute the xxx for a real IP address, cause I'm not disclosing my VPS IP address):
xxx.xxx.xxx.xxx:3000
The page never comes up and eventually it times out.
I've tried various ports (8080, 7000) and to not avail.
Do I need to place the iOS project in a different directory.
Currently I have it in /root/Projects/NodeTutorial2/index.js.
What do I need to do to get a hello world response from my VPS?
If you're getting a response from on the box, but not from other boxes, it's almost certainly a firewall issue. Turning off IPTables or allowing the traffic in on the port in question is one option but an easier / more appropriate option is to simply have your app use port 80 (for HTTP) or 443 (for HTTPS). You can either do that by listening to that port on the app directly, or by having a web server that acts as a reverse-proxy for you (e.g. NGINX or Apache).
I installed node.js and socket.io in my CentOS 6.4 server. It is running parallel with Apache, with Apache as main server (port 80)
I wrote a simple Hello world script to test node.js installation:
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.write('Hello World\n');
response.end();
}).listen(8088);
console.log('Server started');
If I run it in command line I get 'Server started'. But when I tryh to access it via web browser, typing http://xxx.xxx.xxx.xxx:8088 it never loads. I've tried to use many other port numbers with no success. I have to ips in my server, but neither of them work, nor my domain addres under those ips.
How could I fix it?
EDIT: node,js is installed in another server, and I'm trying to access it via webbrowser from outside this server.
Thanks!
i think you need to open port 8088 by firewall on server.
see man iptables