[英]Dedicated web server, nodeJS can't run app
Ok I have setup my own webserver on a pc running fedora server. 好的,我已经在运行fedora服务器的PC上设置了自己的Web服务器。 Everything is configured properly.
一切都配置正确。 I have my dns server pointing my domain to the IP and can connect.
我的dns服务器将我的域指向IP,并且可以连接。 The problem is that I want to run a node app on the server.
问题是我想在服务器上运行节点应用程序。 I can't find the right guide or examples.
我找不到正确的指南或示例。 What it seems, is that I have to run 'node app' on the server through terminal.
看来,我必须通过终端在服务器上运行“ node app”。 Everytime I do, I get this error.
每当我这样做时,都会收到此错误。
Error: listen EADDRINUSE 192.168.1.5:8080
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at Server._listen2 (net.js:1258:14)
at listen (net.js:1294:10)
at net.js:1404:9
at _combinedTickCallback (internal/process/next_tick.js:83:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
From what I have read, it means the port isn't open. 据我了解,这意味着该端口未打开。 Yet it is.
是的 What am I doing wrong, and how can I fix this.
我在做什么错了,我该如何解决。 The same code changed to this pc works fine locally.
更改为此PC的相同代码在本地可以正常工作。
var http = require('http'),
express = require('express'),
app = express();
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8080, '192.168.1.5');
console.log('Server running at http://192.168.1.5:8080/');
You can see what processes are using that port with 您可以查看哪些进程正在使用该端口
sudo netstat -tulpn | grep 8080
The last column is "PID/Program name" get the pid that's running on that port, then run 最后一列是“ PID /程序名称”,获取在该端口上运行的pid,然后运行
sudo kill -9 <pid>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.