When your website returns a 404 (Not Found) error, it means the requested page cannot be found on the server. This can be caused by:
If your domain is not resolving correctly, it could cause a 404 error.
To manually check DNS from the terminal:
nslookup yourdomain.com
or
dig yourdomain.com
If the IP does not match your server, update the DNS settings.
If you recently updated your DNS, check propagation:
It may take up to 24 hours to fully propagate.
Solution: If DNS is incorrect, update your nameservers or A records in your domain registrar.
A 404 error can occur if the requested file does not exist or is misplaced.
In cPanel:
public_html/Your homepage file must be named index.php or index.html.
If missing, upload it to public_html/.
To check via SSH:
ls -la /home/yourusername/public_html/
If index.php or index.html is missing, upload your website files.
If permissions are incorrect, Apache/Nginx cannot serve the files.
sudo chmod -R 755 /home/yourusername/public_html/
sudo chmod 644 /home/yourusername/public_html/index.php
For cPanel users:
Restart Apache:
sudo systemctl restart apache2
or for Nginx:
sudo systemctl restart nginx
.htaccess in public_html/mv .htaccess .htaccess_backupIf it works, restore .htaccess and check for misconfigured rules like:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
If .htaccess was the issue, regenerate permalinks (for WordPress sites) in:
WordPress Admin > Settings > Permalinks > Save Changes
If you have multiple domains or subdomains, check your Apache Virtual Host settings.
For Apache:
sudo nano /etc/apache2/sites-available/000-default.conf
Ensure:
<VirtualHost *:80>
DocumentRoot /home/yourusername/public_html
ServerName yourdomain.com
</VirtualHost>
For Nginx:
sudo nano /etc/nginx/sites-available/default
Ensure:
server {
root /home/yourusername/public_html;
server_name yourdomain.com;
}
Restart your web server:
sudo systemctl restart apache2
or
sudo systemctl restart nginx
Press Ctrl + Shift + R or clear cache from browser settings.
| Issue | Fix |
|---|---|
| Incorrect DNS records | Check via dig yourdomain.com and update DNS |
| Files missing in public_html/ | Ensure files are correctly placed |
| Missing index.php or index.html | Upload and set correct permissions (644) |
| Incorrect file permissions | chmod -R 755 /home/yourusername/public_html/ |
| Misconfigured .htaccess | Rename .htaccess and regenerate |
| Virtual Host misconfiguration | Check Apache/Nginx settings |
| Cache issues | Clear browser cache & CDN cache |
After following these steps, your website should load correctly!