tileserver-gl icon indicating copy to clipboard operation
tileserver-gl copied to clipboard

Error: listen EACCES: permission denied 0.0.0.0:80

Open aconital opened this issue 3 years ago • 10 comments

I have a simple ubuntu server and when I run the following command: docker run --rm -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl I get this error:

    at Server.setupListenHandle [as _listen2] (net.js:1263:19)
    at listenInCluster (net.js:1328:12)
    at Server.listen (net.js:1415:7)
    at Function.listen (/app/node_modules/express/lib/application.js:618:24)
    at start (/app/src/server.js:450:22)
    at module.exports.opts (/app/src/server.js:469:19)
    at startServer (/app/src/main.js:80:29)
    at fs.stat (/app/src/main.js:211:12)
    at FSReqWrap.oncomplete (fs.js:154:5)
Emitted 'error' event at:
    at emitErrorNT (net.js:1307:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)

I tried running it with sudo as well but same thing. I had no issue running the same command on the same server last week.

aconital avatar Dec 14 '20 19:12 aconital

I got this error as well while trying to run v3.1.1. I also tried running the same command with v3.1.0, and even though it didn’t give any explicit error messages during start up the viewer wouldn’t even open up on the designated port. The same command was working properly with V3.0.0 though.

eitProp avatar Dec 15 '20 23:12 eitProp

Try to use -u 0 in order to run it as root : docker run --rm -u 0 -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl This works perfectly

hassan-essabir avatar Dec 22 '20 11:12 hassan-essabir

Do we need to run it as root though? Previous versions were working fine.

aconital avatar Dec 23 '20 14:12 aconital

It runs as root inside the container only. They are trying to bind to the port 80 as a non root user which is never gonna work unless the user is a sudoer. For me, it's a regression that needs to be fixed by maptiler. The solution I suggested is only a work around.

hassan-essabir avatar Dec 23 '20 17:12 hassan-essabir

I would suggest running the container on another port instead of the default 80. I use this in my Kubernetes manifest:

- name: tileserver
        image: maptiler/tileserver-gl
        args: ["-p", "8080", "--verbose", "-c", "/var/config/<my_config>.json"]

In Compose:

tileserver:
    image: maptiler/tileserver-gl
    ports:
      - "8080:8080"
    volumes:
      - "$PWD/data:/data"
      - "$PWD/tileserver/config:/var/config:ro"
      - "$PWD/tileserver/static:/var/static:ro"
    command: -p 8080 --verbose -c /var/config/<my_config>.json

In Docker Run: docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl -p 8080 --verbose

Running as root is not necessary then.

StephanZaat avatar Dec 24 '20 12:12 StephanZaat

I had the same problem and the solution from @StephanZaat worked fine! I use tileserver gl on Dokku and I added this to my Dockerfile:

EXPOSE 8080
CMD ["-p", "8080", "--verbose"]

Basically the solution above but for a Dockerfile.

bonny avatar Dec 25 '20 14:12 bonny

Try to use -u 0 in order to run it as root : docker run --rm -u 0 -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl This works perfectly

Thanks for this workaround, it works just fine, but can you tell me how do I write "-u 0" in docker-compose file?

RilusMahmud avatar Sep 16 '21 07:09 RilusMahmud

I feel like we should introduce some param to disable the --user docker option. This way if the user wants to run all their docker images as root, they can. This might also help solve the issue some Mac users have reported with performance using shared volumes.

nyurik avatar Sep 16 '21 13:09 nyurik

We had the same issue in some environments. We are not completely sure when it occurs but contributing factors seem to be

  • no node user on the host
  • specific docker and podman versions We fixed it in #578 by explicitly allowing node to start on the lowport.

candux avatar Mar 27 '22 20:03 candux

we have changed the internal docker port from 80 to 8080, so I think this issue should be resolved.

Note, the ports in the command have changed from 8080:80 to 8080:8080 due to this change, starting in v4.2.0 docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl

acalcutt avatar Nov 24 '22 17:11 acalcutt