By Samuel
My website is Loading via Domain, but i cant load it via IP address, i keep getting error 404. And all the dns look ups are fine.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi Samuel!
If your website loads via the domain but gives a 404 error when accessed via the IP address, it’s likely due to how your web server (like Nginx or Apache) is configured.
Basically, web servers use Virtual Hosts (in Apache) or Server Blocks (in Nginx) to map requests to the correct site based on the domain name (the Host
header). If no specific configuration matches the IP address, the server returns a default 404 error.
To learn more about virtual hosts and server blocks check out these two articles:
For Nginx:
For Apache:
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-20-04
To fix this you will have to check a few things:
Check Virtual Host or Server Block Configuration
Make sure your server configuration includes a default host that serves your website when accessed via the IP.
For Apache:
<VirtualHost *:80>
ServerName your_domain.com
ServerAlias your_server_ip
DocumentRoot /var/www/html
</VirtualHost>
For Nginx:
server {
listen 80;
server_name your_domain.com your_server_ip;
root /var/www/html;
}
Restart the Web Server
After updating the configuration, restart your web server:
sudo systemctl restart apache2 # For Apache
sudo systemctl restart nginx # For Nginx
Check Firewall Settings
Ensure port 80 (HTTP) or 443 (HTTPS) is open:
sudo ufw allow 'Apache Full' # For Apache
sudo ufw allow 'Nginx Full' # For Nginx
Verify the IP Address
Confirm you are using the correct public IP of your server.
Feel free to share more details on your exact setup and the guides that you’ve follow to set it all up and I can give you more information on how you could solve this if the above does not work.
Let me know if this helps!
- Bobby
Heya,
This is entirely up to your Nginx/Apache configuration. Can you share which one you are using? So, basically, it’s not related to your Domain but your WebService configuration file.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.