skip to Main Content

I was using a dev environment with Windows and WSL with docker and nginx installed directly in my WSL machine to handle the proxy reverse, but now when I’m trying to start nginx, I’m getting the error "98: Unknown error" and using the command "sudo nginx -t", it shows me "bind() to 0.0.0.0:80 failed" and "0.0.0.0:443 failed", what can I do to fix this?

2

Answers


  1. problem

    ubuntu wsl comes with apache web server pre-installed, its using the default web port (80), so when you try to start nginx with default setting (also on port 80) it will have bind error

    but of-course, there are multiple reason that port 80 is already used, in which you need to check what app that is using it

    how to check

    option 1:

    • open the ubuntu (linux) terminal
    • type sudo systemctl status apache2
    • if you see some message that tells its running, then it does using port 80, if not, then its something else

    option 2:

    • open a browser and type localhost in the address bar
    • if its showing default apache install page, then its truly the culprit

    solution

    this solution is for when apache2 is the culprit, for any other app that might use port 80, you need to find how to disable it yourself

    • stop it using sudo systemctl stop apache2
    • you need to disable it too, so that next time you restart your pc, it wont auto-start, type sudo systemctl disable apache2
    • after this, you can try starting the nginx again: sudo systemctl start nginx
    • and make it auto-start: sudo systemctl enable nginx

    of-course, you can just change the port used by nginx like here use other port on nginx

    if you decide to change nginx port, please note that any host listening on port that is used by other app will make nginx fail to start, so if you have more than 1 host on nginx config, you need to update them too

    Login or Signup to reply.
  2. I was playing around local nginx proxy with nodejs API listening at port :5000. Had same and other permission errors, finally I realized that port 80 is already being used by my local IIS.

    Stopped IIS to free port :80 and restarted nginx service.

    sudo service nginx restart
    

    There are other stuffs too that are confusing but atleast I can see my nginx in action and working.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search