Deno Uncaught AddrInUse:每个套接字地址(协议/网络地址/端口)通常只允许使用一种。 (操作系统错误10048)

时间:2020-06-04 07:26:18

标签: deno

当我尝试运行我的Deno文件时,我得到了os error 10048,如何解决该错误?谢谢

 import { Application } from 'https://deno.land/x/oak/mod.ts'

const app = new Application();
const port = 3000;

app.use((ctx) => {
    ctx.response.body = "Hello World"
})

app.listen({ port })
console.log(`localhost:${port}`)

我尝试运行我的Deno文件,但出现此错误

D:\Deno Documentation\deno3>deno run --allow-net ./server.js
localhost:3000
error: Uncaught AddrInUse: Only one usage of each socket address (protocol/network address/port) is normally permitted. (os error 10048)
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
    at Object.listen ($deno$/ops/net.ts:51:10)
    at listen ($deno$/net.ts:152:22)
    at Application.serve (https://deno.land/std@0.56.0/http/server.ts:252:20)
    at Application.listen (https://deno.land/x/oak/application.ts:295:20)
    at file:///D:/Deno%20Documentation/deno3/server.js:10:5

2 个答案:

答案 0 :(得分:2)

您有另一个程序正在监听端口3000,将该端口更改为未使用的端口,或者杀死正在3000上运行的程序。

答案 1 :(得分:1)