0

my domain name, "codeplane.dev", (who's IP address is updated periodically using Google's dydns API), can be pinged and displays the correct IP address when pinged, but whenever I attempt to visit the domain in Firefox, the request times out. This behavior only happens whenever I use the domain name, whenever I enter the IP address displayed by the ping command into Firefox, the website is displayed just fine. What should I do, in-order to ensure that whenever I enter my domain in the browser, my webpage is displayed?

Here's my website configuration for apache: codeplane.dev.conf

<VirtualHost *:80>
    ServerName codeplane.dev
    ServerAlias www.codeplane.dev
    DocumentRoot /var/www/codeplane.dev/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
    ServerName codeplane.dev
    ServerAlias www.codeplane.dev
    DocumentRoot /var/www/codeplane.dev/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
  • 1
    Is the server behind that IP address running a web server like Apache or nginx? Is port 80 open and accepting http connections? – Bert Dec 21 '20 at 19:38
  • 3
    Don't host it at home. – Michael Hampton Dec 21 '20 at 20:29
  • @Bert Yes, and whenever I type the IP address returned from the ping command, into firefox (currently 47.220.138.92), the website is displayed just fine. It's only when I use the domain that the browser times out. – SuperSim135 Dec 21 '20 at 20:54
  • Answer please, NGINX or Apache, because you tagged it as apache however, for dev domain is SSL mandatory so you wont access your site with http usually - and by the way post your config - do us a favor ps auxwww|grep nginx and lsof -i :80,433 output please – djdomi Dec 23 '20 at 05:53
  • @djdomi I'm using Apache2 as my web server. – SuperSim135 Dec 26 '20 at 20:48
  • Your SSL configuration is missing. – Michael Hampton Dec 26 '20 at 21:10
  • @MichaelHampton That's what I guessed, but whenever I tried to use Certbot to get my certificate, using the command 'sudo certbot --apache' it failed with the message 'Timeout during connect (likely firewall problem)'... – SuperSim135 Dec 28 '20 at 00:47
  • @supersim135 please run `lsof -i :80,443` and tell us the output – djdomi Dec 31 '20 at 20:59
  • `ping` is almost never a troubleshooting tool. Also, all `.dev` domains require a certificate, hence port 443 only (not 80) because of Google adding the TLD in HSTS preloading list. Like their others TLDs such as .app or .new – Patrick Mevzek Jan 01 '21 at 21:07

4 Answers4

2

Ping answers to ICMP packets and web access use to listen on TCP/80 and/or TCP/443.

If you can ping your host, means that probably your firewall is allowing ICMP packets.

If you can't access your website or API from the browser, that can be caused by different things:

  1. First, double-check your firewall rules and confirm ports TCP 80 and/or 443 are allowed

You can also try this from the command-line:

curl http://yoursite.example
curl -I http://yoursite.example
  1. Look into your server's log and check if you can see your request reaching your server.

If so, it's probably because your application isn't answering properly, which means you'll have to debug it on the application layer

If it's not, it's probably by your firewall blocking HTTP/HTTPS packets or your webserver isn't up. So, try starting it

EDIT To have you apache server answering for specific domains, you'll need to add a VirtualHost config. To do this:

Create a file /etc/apache2/sites-available/yourdomain.conf with the following content:

<VirtualHost *:80>
    ServerName yourdomain.example
    ServerAlias www.yourdomain.example
    DocumentRoot /var/www/yourdomain/public/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

adjust its configuration (domain and directories) according to your site and add a symbolic link to sites0-enabled:

ln -s /etc/apache2/sites-available/yourdomain.conf /etc/apache2/sites-enabled/yourdomain.conf

Restart apache2.

I also suggest you reading this howto: How To Set Up Apache Virtual Hosts on Ubuntu 18.04

Patrick Mevzek
  • 9,273
  • 7
  • 29
  • 42
surfingonthenet
  • 695
  • 2
  • 6
  • curl http://codeplane.dev, outputs the html of the page in the console, so this must mean there's a problem with my site? Also, whenever I type the IP address returned from the ping command, the site is displayed just fine. It's only when I use the domain, that it times out. – SuperSim135 Dec 21 '20 at 20:53
  • @SuperSim135, so you need to configure your webserver (apache, nginx, IIS, etc) to listen for your domain name. What webserver are you using? – surfingonthenet Dec 22 '20 at 19:04
  • I'm using apache2 to host my website – SuperSim135 Dec 22 '20 at 19:27
  • @SuperSim135, I just updated my answer. Please take a look – surfingonthenet Dec 23 '20 at 02:15
  • My configuration is basically exactly like this one and the domain still times out. I think the reason my website is failing to load whenever I use the domain, is because the domain that I'm updating "codeplane.dev", doesn't have a proper sub-domain like "www". I'm going to change this and see what happens. – SuperSim135 Dec 23 '20 at 02:24
  • Copying and pasting your configuration (*Changing case specific information), still leads to the same result. The browser timing out. Could there be another reason for this? I thought it might have also been the fact that I didn't specify a proper subdomain, but this also changed nothing. – SuperSim135 Dec 23 '20 at 02:44
  • @SuperSim135, did you check apache logs? Have the requests been logged? – surfingonthenet Dec 23 '20 at 16:25
  • No, I'm still trying to figure out how to check the apache logs, however, using a tool called 'httpry', which logs all http requests sent to my server, only shows http requests being sent whenever I run 'curl www.codeplane.dev' on another machine or enter the IP address directly into my browser. It still doesn't show a request when I type the domain into my browser window. – SuperSim135 Dec 24 '20 at 05:38
  • Try `curl https://domainname` . If that fails, but `curl http://domainname` succeeds, it's because the server isn't correctly handling https/443 -- check the Listen config -- and the browser is forcing https even when you don't specify it because, as djdomi commented, `.dev` is in the HSTS preload list – dave_thompson_085 Dec 27 '20 at 02:23
1

You have a web site that answers correctly when called using its IP address, but not when called using its name.

This means your web server is not configured correctly: web servers choose the content to serve based on (amongst other things) the host name used in the HTTP request; that's how you can host different web sites the same system: same IP address, different names.

If the web server replies to unnamed request (those done using its IP address without any specific host name) but not to named ones, you should check its config and make sure it actually knows it should answer to that name.

Since you can actually see your website by pointing at its IP address, this rules out firewall or networking issues; this seems to be specifically a web server problem.

Massimo
  • 68,714
  • 56
  • 196
  • 319
0

Because a PING is different from a website. You basically ask "in my car, why is my air conditioning working, but not my radio". Your car, different devices. If you did ONLY what you said - why the heck would you expect firefox to do anything else? Unless it has a WWW server that answers (which you say NOTHING about) - a normal end user router will not even answer.

TomTom
  • 50,857
  • 7
  • 52
  • 134
  • The reason I framed the question this way is because when I type the IP address that the ping command returns, my website is displayed just fine. It's only when I type in my domain, that things stop working. – SuperSim135 Dec 21 '20 at 20:50
0

SuddenLink and many other ISPs (internet service providers), have blocked ports 80 and 443. This means that despite the broad and detailed responses to this question, the only real solution is to host somewhere where these ports aren't blocked, or use an ISP that's less greedy.