节点js +错误:收听EADDRINUSE +未处理的'错误'事件

编程入门 行业动态 更新时间:2024-10-27 22:21:37
本文介绍了节点js +错误:收听EADDRINUSE +未处理的'错误'事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 nodeclipse 插件为eclipse运行我的节点js项目。以下js文件工作正常,但 h1 标记无法正常工作。我只能看到一个纯文本。我在运行时获取此异常。请帮助我。

I'm using nodeclipse plugin for eclipse to run my node js project.Following js file is working properly but h1 tag is not working .I can only see a plain text.plus I'm getting this exception in the runtime.please help me out.

javascript文件

var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/html'}); response.end('<html><body><h1>Home</h1> URL was: ' + request.url + '</body></html>'); }).listen(3000, 'localhost'); console.log('Server running at localhost:3000/');

例外

events.js:72 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE at errnoException (net.js:904:11) at Server._listen2 (net.js:1042:14) at listen (net.js:1064:10) at net.js:1146:9 at dns.js:72:18 at process._tickCallback (node.js:415:13) at Function.Module.runMain (module.js:499:11) at startup (node.js:119:16) at node.js:902:3

推荐答案

错误:listen EADDRINUSE

此错误表示您已经有另一个进程正在侦听端口3000.

This error means that you already have another process listening on port 3000.

以下是如何找出它在Windows上的流程

C:\> netstat -a -b (add -n to stop it trying to resolve hostnames, which will make it a lot faster) Edit: +1 for Dane's recommendation for TCPView. Looks very useful! -a Displays all connections and listening ports. -b Displays the executable involved in creating each connection or listening port. In some cases well-known executables host multiple independent components, and in these cases the sequence of components involved in creating the connection or listening port is displayed. In this case the executable name is in [] at the bottom, on top is the component it called, and so forth until TCP/IP was reached. Note that this option can be time-consuming and will fail unless you have sufficient permissions. -n Displays addresses and port numbers in numerical form.

更多推荐

节点js +错误:收听EADDRINUSE +未处理的'错误'事件

本文发布于:2023-08-07 14:02:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1319459.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   节点   事件   未处理   EADDRINUSE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!