How To Troubleshoot When your site is down on a Linux Server
Sometimes we may run in to troubles when one of our web-server or site is down,We should be able to identify this problem which are likely causing the issues and fix the problem.
Please follow the below steps which are the some of the common steps taken by administrators when a site is not accessible correctly. We can refer this steps and fix the issue so that wwe can get the site up and running.
- Access to the Linux server with root or sudo user. If you are not able to login to your server,Chances are that your server is down or in hanged state
- Before proceeding futher, first check the server status with the below command in the example. Replace the Ip with your Ip. You will get the output which is in the example.
Note:- You may sometimes not be able to ping the server even when your server is UP and this may be due to ping being disabled on your server
ping your server ip
Ex:- ping 1.2.3.4
PING 1.2.3.4 (1.2.3.4) 56(84) bytes of data.
64 bytes from 1.2.3.4: icmp_seq=1 ttl=49 time=367 ms
64 bytes from 1.2.3.4: icmp_seq=2 ttl=49 time=390 ms
64 bytes from 1.2.3.4: icmp_seq=3 ttl=49 time=300 ms - If your server is down,in that case you will get not get any ping.
- After that we need to check the logs. If you have an Apache server running on an Ubuntu server, by default the logs will be kept in /var/log/apache2. If you’re using a distribution that refers to Apache as httpd by default the logs will be kept at /var/log/httpd.log. If you are using Nginx as your web server,The logs are usually located at below location.
/var/log/nginx/access.log
/var/log/nginx/error.log
/var/log/nginx/nginx_error.log
/var/log/nginx/access_error.log - Check the files in this directory to see what kind of error messages are being generated. Based on the error we need to troubleshoot.
- To check the latest logs generated from the server,You can run below tail command as shown in below example.
tail -f /var/log/nginx/access.log
tail -f /var/log/httpd.log - Make sure your web server is running.
service apache2 status - If the web server is in stopped state then start it with the below command.
service apache2 start
If you are using httpd then use the below command.
service httpd start
If you are using nginx then use the below command.
service nginx start - Verifying the Syntax of Web server. Please use the below commands.
nginx:- nginx -t
apache2:- apache2ctl -t
httpd:- httpd -t - Once you run the above command you will get the message like Syntax OK or Test is successful. This means that no issues at your web server configuration.If you get message like “test failed” then there is an invalid argument which are provided in the configuration file and that needs to be edited.
- Check the database back-end running fine. Run the below command to verify if your database MySQL/Mongod whichever you are running.
service mysql status
service mongod status - If mysql or whatever the database is not running then start it with the below command. If you are unable to start, you need to check the logs.
ex:- tail -f /var/log/mysql/error.log
less /var/log/mysql/error.log
According to the error you need to troubleshoot. - Make sure the Ports are open. You can check whether if the configured ports are open with telnet command.
telnet 1.2.3.4 80
telnet 1.2.3.4 443
telnet 1.2.3.4 3306 - By performing the above steps you will know where the issues is and based on that you need to troubleshoot and solve the issue.