Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to change port to 80 on webpack-dev-server gives error

I have this in my package json:

webpack-dev-server --config config/webpack.config.js --port 80

I have also tried adding the port to the config like so:

devServer: {
  historyApiFallback: true,
  host: '0.0.0.0',
  port: '80',
},

and it gives the same error:

webpack-dev-server --config config/webpack.config.js --port 80

loader option has been deprecated - replace with "use"
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: listen EACCES 127.0.0.1:80
    at Object.exports._errnoException (util.js:1034:11)
    at exports._exceptionWithHostPort (util.js:1057:20)
    at Server._listen2 (net.js:1257:19)
    at listen (net.js:1306:10)
    at doListening (net.js:1421:7)
    at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:62:16)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:78:10)

Any help with something i'm doing wrong appreciated, or with what the error is in relation to. Thanks

like image 504
alexrogers Avatar asked Dec 10 '22 12:12

alexrogers


2 Answers

How to fix

You will need to either run as root using sudo, or setup a proxy that redirects requests on port 80 to a port over 1024.

Why it doesn't work

Regular users cannot listen on ports lower than 1024, so you cannot listen on port 80.

like image 197
jrtapsell Avatar answered Jan 02 '23 16:01

jrtapsell


I'm using Ubuntu and have the exact same issue with port 80. After I add "sudo" in front of "npm run dev" the issue disappears.

like image 31
Shifa Zhang Avatar answered Jan 02 '23 14:01

Shifa Zhang