My website is down after rebooting my Linode - Showing default nginx/apache page.
I have both Nginx and apache installed on my webserver. After rebooting my Linode, my website is down and loads the default Nginx/apache webpage. How do I fix this?
1 Reply
This sounds like a port conflict. A default webpage for Apache or Nginx is generated when there is another process listening on the same port that Apache/Nginx is configured to use. If another web server like Nginx is configured to listen on port 80 and it is running, then Apache will not be able to claim the port for itself and it looks like this happens to be the case.
You need to determine what other process is listening on the IP address and port that Apache is attempting to use. The following command will determine the name of the process that is already bound to an IPv4 interface on port 80:
sudo ss -4 -tlnp | grep 80
You should get an output that looks similar to the one below:
Output
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=40,fd=6))
You'd want to pay attention to the 4th field 0.0.0.0:80
which matches the IP address and port reported by journalctl and also the last field users:(("nginx",pid=40,fd=6))
, this tells us the process currently running. This process is preventing Apache from starting since it already owns the port.
Next, you'll use the ps
utility to determine the name of the program using that IP and port by running sudo ps -p 40
. (Make sure you subtitute 40 with the pid that matches your output after running sudo ss -4 -tlnp | grep 80
). The output should be similar to something like this:
Output
PID TTY TIME CMD
40 ? 00:00:00 nginx
With this information, you can either stop the Nginx process by running sudo kill $pid
where $PID is the process ID of the Nginx process and restart apache with sudo service apache2 restart
or reconfigure apache to listen on a different interface.
Depending on which default page(Apache/Nginx) you're seeing, you can just stop the rouge service and start either of them that runs your website. For example, if your website is showing a default Nginx page, use the following two commands:
sudo service nginx stop
sudo service apache2 start
For a default Apache webpage, run the same command above but stop apache instead and start Nginx.
sudo service apache2 stop
sudo service nginx start