Search code examples
apachepermissionsroot

Apache won't start due to "Failed password for root from ..."


I get this error when I try to start apache:

balter@balterbox:/etc/apache2$ sudo service apache2 restart
Job for apache2.service failed because the control process exited with error code.
See "systemctl  status apache2.service" and "journalctl  -xe" for details.

Here are the logs:

balter@balterbox:/etc/apache2$ sudo systemctl status apache2.service
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Fri 2018-02-16 14:45:58 PST; 33s ago
  Process: 2534 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
      CPU: 34ms

and

balter@balterbox:~$ sudo journalctl -xe | tail
Feb 16 15:05:17 balterbox sshd[2777]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=###.###.###.###  user=root
Feb 16 15:05:19 balterbox sshd[2777]: Failed password for root from ###.###.###.### port 33812 ssh2
Feb 16 15:05:19 balterbox sshd[2779]: Connection closed by 114.32.120.181 port 47696 [preauth]
Feb 16 15:05:21 balterbox sshd[2777]: Failed password for root from ###.###.###.### port 33812 ssh2
Feb 16 15:05:24 balterbox sshd[2777]: Failed password for root from ###.###.###.### port 33812 ssh2
Feb 16 15:05:24 balterbox sshd[2777]: Received disconnect from ###.###.###.### port 33812:11:  [preauth]
Feb 16 15:05:24 balterbox sshd[2777]: Disconnected from authenticating user root 121.18.238.39 port 33812 [preauth]
Feb 16 15:05:24 balterbox sshd[2777]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=###.###.###.###  user=root
Feb 16 15:05:29 balterbox sudo[2781]:   balter : TTY=pts/2 ; PWD=/home/balter ; USER=root ; COMMAND=/bin/journalctl -xe
Feb 16 15:05:29 balterbox sudo[2781]: pam_unix(sudo:session): session opened for user root by balter(uid=0)

EDIT: Result of @Carlo's suggestion:

balter@balterbox:~$ sudo apache2ctl restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
httpd not running, trying to start
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'restart' failed.
The Apache error log may have more information.
balter@balterbox:~$ sudo apachectl restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
httpd not running, trying to start
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'restart' failed.
The Apache error log may have more information.
balter@balterbox:~$ sudo /etc/init.d/apache2 restart
[....] Restarting apache2 (via systemctl): apache2.serviceJob for apache2.service failed because the control process exited with error code.
See "systemctl  status apache2.service" and "journalctl  -xe" for details.

Why is it failing to open logs?


Solution

  • From the wonderful folks at Digital Ocean:

    You can ignore the "Failed password for root" errors in this situation - they're for the SSH server, not the web server. For that reason, you'd need to remove tail from the journalctl command and page up or down in the file to find some lines about Apache specifically.

    The output of apache2ctl restart that you added shows the issue though - something is already listening on port 80, so Apache can't start listening for connections on that port number. You can run a command like sudo netstat -tnlp to get a list of running processes that are listening for connections and look for the one whose local address ends in :80. Stop that corresponding service and then try starting Apache again.

    Turns out I also had Nginx running (I had installed it to do a little experimentation). Turned of Nginx, and was able to start Apache.

    Also, special Kudos to @Carlo Federico Vescovo for sticking with it.