我刚刚为我的新服务器( hostgater VPN SERVER )创建了一个示例测试文件来测试节点js Application?当我看到它从终端后端运行时我感到很震惊但是当我从浏览器访问它时显示 &#34;无法连接&#34; 。< / p>
我有Centos Server 6.7 final
我遵循的步骤
节点 - v 4.4.4 npm -v 2.15.1
Server.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(3000);
console.log('Server running at 3000/')
它的运行成功并控制了消息,但是当我开始在浏览器 xyz.com:3000 上收听应用程序时。它显示无法连接。
我无法理解我所缺少的东西,任何人都可以指导我。
答案 0 :(得分:1)
与您的服务器托管服务提供商(Hostgater)联系,让他们将端口3000转发到您的服务器。
另一个解决方案可能是使用端口80而不是3000,因为该端口很可能已经打开并转发。
答案 1 :(得分:1)
请在浏览器中添加一些路线或添加
<?php
// Time Record Start
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
require_once("models/header.php");
echo "
<body>
<div align='center'>";
echo "
</div>
<div id='wrapper'>
<div id='top'><div id='logo'></div></div>
<div id='content'>
<h1>site</h1>
<h2>Internal Contact Management</h2>
<div id='left-nav'>";
include("left-nav.php");
echo "
</div>
<div id='main'>
Hey, $loggedInUser->displayname.</br></br>
<div align='center'><a href='admin_contacts_add.php'>Add</a></div>";
include('conn.php');
$query1=mysql_query("select * from contacts ORDER BY `contacts`.`name` ASC");
echo "<table align='center' width='60%'>
<tr>
<td><b>Name</b></td>
<td><b>Phone</b></td>
<td><b>Ext</b></td>
<td><b>Mobile</b></td>
<td><b>Edit</b></td>
<td><b>Delete</b></td>";
while($query2=mysql_fetch_array($query1))
{
echo "<tr><td>".$query2['name']."</td>";
echo "<td>".$query2['phone']."</td>";
echo "<td>".$query2['ext']."</td>";
echo "<td>".$query2['mobile']."</td>";
echo "<td><a href='admin_contacts_edit.php?id=".$query2['id']."'>Edit</a></td>";
echo "<td><a href='admin_contacts_delete.php?id=".$query2['id']."'>Delete</a></td><tr>";
}";
</ol>
</table>
</div>";
// Time Calculate and generate
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
$page = 'admin_contacts_view.php';
echo '</br>';
echo '<div align="center">Penguins generated this in '.$total_time.' seconds.</div>';
// Insert Time Data
$sql = "INSERT INTO preformance (page, time) VALUES('$page', '$total_time')";
$insert = $mysqli->query($sql);
echo "
<div id='bottom'></div>
</div>
</body>
</html>";
?>