0

I have just bought a new droplet from digitalocean, and i installed nginx with sudo apt install nginx tried to see if it ran, and it gave me following error:

root@school:~# systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2019-05-20 19:27:11 UTC; 22s ago
     Docs: man:nginx(8)
  Process: 21174 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 21160 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 851 (code=exited, status=0/SUCCESS)

May 20 19:27:10 school nginx[21174]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
May 20 19:27:10 school nginx[21174]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
May 20 19:27:10 school nginx[21174]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
May 20 19:27:10 school nginx[21174]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
May 20 19:27:11 school nginx[21174]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
May 20 19:27:11 school nginx[21174]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
May 20 19:27:11 school nginx[21174]: nginx: [emerg] still could not bind()
May 20 19:27:11 school systemd[1]: nginx.service: Control process exited, code=exited status=1
May 20 19:27:11 school systemd[1]: nginx.service: Failed with result 'exit-code'.
May 20 19:27:11 school systemd[1]: Failed to start A high performance web server and a reverse proxy server.

This is my firewall settings:

To                         Action      From
--                         ------      ----
80/tcp                     ALLOW       Anywhere                  
22                         ALLOW       Anywhere                  
3306                       ALLOW       Anywhere                  
Apache                     ALLOW       Anywhere                  
Nginx HTTP                 ALLOW       Anywhere                  
Nginx HTTPS                ALLOW       Anywhere                  
80/tcp (v6)                ALLOW       Anywhere (v6)             
22 (v6)                    ALLOW       Anywhere (v6)             
3306 (v6)                  ALLOW       Anywhere (v6)             
Apache (v6)                ALLOW       Anywhere (v6)             
Nginx HTTP (v6)            ALLOW       Anywhere (v6)             
Nginx HTTPS (v6)           ALLOW       Anywhere (v6)

Is this clear to any of you what the issue is? Thanks for your time

sudo netstat -tlpn | grep :80

gave following results:

root@school:~# sudo netstat -tlpn | grep :80
tcp6       0      0 :::80                   :::*                    LISTEN      16792/apache2 
  • Do you have any other webserver running? – vidarlo May 20 '19 at 19:33
  • I will look into that, I'll be back – Jonas Grønbek May 20 '19 at 19:34
  • I would say no, I have literally just bought the server – Jonas Grønbek May 20 '19 at 19:35
  • Please run sudo netstat -tlpn | grep :80 and edit your post to include the output. – vidarlo May 20 '19 at 19:36
  • I have edited my question, it seems like there is an apache server running – Jonas Grønbek May 20 '19 at 19:38
2

The results of sudo netstat -tlpn | grep :80 indicate that you have Apache running. Two processes can't listen to the same socket at once, so that's why nginx can't start.

You can stop Apache with sudo systemctl stop apache2, and if you want, disable it with sudo systemctl disable apache2. The latter command will permanently disable automatic start of Apache.

If you want to remove Apache, run sudo apt remove apache2 apache2-data apache2-utils.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.