Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
752 views
in Technique[技术] by (71.8m points)

javascript - Node.js consistently giving 503 error

I just installed Node.js, got it working for a while, then tried to run a standard Hello World program.

var http = require("http");

http.createServer(function (request, response) {

   // Send the HTTP header
   // HTTP Status: 200 : OK
   // Content Type: text/plain
   response.writeHead(200, {'Content-Type': 'text/plain'});

   // Send the response body as "Hello World"
   response.end('Hello World
');
}).listen(8081);

// Console will print the message
console.log('Server running at http://127.0.0.1:8081/');

I then launched the domain I set up for node, http://node.foobar.com - I successfully got it to print Hello World when I did the same on my domain last week. However now, I keep getting 503 Service Temporarily Unavailable error.

This happened last week too, after I closed the server, edited the code, then reran the server, it would 503 unless I waited a few minutes before running again. However, waiting makes no difference this time.

Apache config for domain:

<VirtualHost *:80>
ServerAdmin zadmin@localhost
DocumentRoot "/var/zpanel/hostdata/zadmin/public_html/node"
ServerName node.foobar.com

ProxyRequests on
ProxyPass / http://localhost:3102/

# Custom settings are loaded below this line (if any exist)
</VirtualHost>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

How do you set up the domain?

Did you use another HTTP server as a proxy?

Please check if node is running, and if yes check your HTTP server is too.

Maybe your node crashed or is just not running.

Another test is to connect your node directly:

http://127.0.0.1:8081/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...