简体   繁体   中英

How do I determine why I'm getting 503 errors on my node.js server?

I am currently teaching myself node.js as a hobbyist. I have a server that I was previously able to get to work with simple 'hello world' outputs. However, I think I might have broken something in my node.js server while doing some tinkering last week and it no longer works. Unfortunately, I am not sure how to troubleshoot the answer and am hoping for direction on that.

The issue is that when I navigate to my domain I just get a 503 error.

However, when I check my node.js log file, the output is displaying my default text that the server is running.

The sample code I'm using is:

    // Load the http module to create an http server.
var http = require('http'),
    sys = require('sys');

// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.end("Hello World\n");
});

// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000);

// Put a friendly message in the log
sys.puts("Server running on port 8000");

Can anyone help me discover the place to find more detailed reasons on why I'm getting a 503?

I looked at the error logs from apache and see this, but have no clue what it means:

[Fri May 30 18:12:09.658627 2014] [proxy:error] [pid 25351:tid 3071591036672] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:8080 (127.0.0.1) failed
[Fri May 30 18:12:09.658713 2014] [proxy:error] [pid 25351:tid 3071591036672] AH00959: ap_proxy_connect_backend disabling worker for (127.0.0.1) for 60s
[Fri May 30 18:12:09.658731 2014] [proxy_http:error] [pid 25351:tid 3071591036672] [client 128.32.70.98:19556] AH01114: HTTP: failed to make connection to backend: 127.0.0.1
[Fri May 30 18:12:10.096354 2014] [proxy:error] [pid 25351:tid 3071599429376] AH00940: HTTP: disabled connection for (127.0.0.1)

Looks like your node.js is configured to listen on port 8000

server.listen(8000);

but apache is trying to connect to port 8080

HTTP: attempt to connect to 127.0.0.1:8080 (127.0.0.1) failed
                                        ^

Configure both application to use the same port (and make sure it is not already in use).

I just had a similar problem. It turns out that my (rust) server was using the ip6 version of localhost - ::1 rather then the ipv4 version - 127.0.0.1, but I had the latter in the Apache proxy command, so they weren't connecting.

I figured this out when I noticed that netstat didn't have my server showing as connecting to 127.0.0.1. An extra confusion was because curl localhost:1234 was connecting correctly. I didn't try it, but perhaps if I'd put localhost into the proxy line it would have worked, too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM