---
title: "linux下node开发笔记（1）"
author: "becomeBetter"
date: "2016-05-05T09:57:26Z"
tags: ["80", "node", "权限", "端口占用"]
categories: ["编程语言"]
slug: "linux-node-1"
draft: false
lastmod: "2016-09-29T15:10:45Z"
id: 2295989
url: "https://becomebetter.iteye.com/blog/2295989"
---

环境：ubuntu12.04 desktop    nodejs 4.4.3

代码如下：

```
var express = require('express');

var app = express();

var path = require('path');

app.use(require('body-parser').urlencoded({extended: true}));

app.use(express.static(path.join(__dirname, 'html/')));

app.listen(80, '127.0.0.1', 50, function(){
	console.log('listen ono port : 80');
});


```

 

会遭遇如下错误：

```
kean@ubuntu:~/Desktop/communityserver$ node app.js 
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: listen EACCES 127.0.0.1:80
    at Object.exports._errnoException (util.js:870:11)
    at exports._exceptionWithHostPort (util.js:893:20)
    at Server._listen2 (net.js:1221:19)
    at listen (net.js:1270:10)
    at net.js:1379:9
    at nextTickCallbackWith3Args (node.js:453:9)
    at process._tickCallback (node.js:359:17)
    at Function.Module.runMain (module.js:443:11)
    at startup (node.js:139:18)
    at node.js:968:3
```

 

 

这个问题是由80端口没有访问权限引起的，将端口改为其他&gt;1024的端口就可以了，或者切换到root用户执行