Can't access droplet by domain, only by IP

June 8, 2017 179 views
Apache Ubuntu 16.04

I've created a droplet from the Wordpress image and I could access it by IP and by domain. I had to rebuild it, but now I can only access it by IP. When I try to access by domain I got Connection Refused error.
Here's how my DNS is set: http://imgur.com/a/lTWQ5

1 comment
2 Answers

@gpressutto5

Please post the output of:

tail -20 /var/log/apache2/error.log

We can check the error log to see if there's any useful errors or warnings being logged that'll help to identify the issue.

  • Here it is, but I don't think they are relevant to this error:

    [Thu Jun 08 16:05:10.746510 2017] [:error] [pid 1554] [client 185.188.205.2:43011] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:11.173779 2017] [:error] [pid 1557] [client 185.188.205.2:44948] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:11.611828 2017] [:error] [pid 2259] [client 185.188.205.2:46941] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:12.033559 2017] [:error] [pid 1558] [client 185.188.205.2:48941] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:12.463302 2017] [:error] [pid 1555] [client 185.188.205.2:50881] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:12.886861 2017] [:error] [pid 1556] [client 185.188.205.2:52755] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:13.313012 2017] [:error] [pid 1554] [client 185.188.205.2:54668] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:13.735015 2017] [:error] [pid 1557] [client 185.188.205.2:56631] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:14.161720 2017] [:error] [pid 2259] [client 185.188.205.2:58554] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:14.586657 2017] [:error] [pid 1558] [client 185.188.205.2:60437] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:15.018564 2017] [:error] [pid 1555] [client 185.188.205.2:34184] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:15.450032 2017] [:error] [pid 1556] [client 185.188.205.2:36136] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:15.879073 2017] [:error] [pid 1554] [client 185.188.205.2:38053] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:16.309254 2017] [:error] [pid 1557] [client 185.188.205.2:39976] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:16.738165 2017] [:error] [pid 2259] [client 185.188.205.2:41891] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:17.166771 2017] [:error] [pid 1558] [client 185.188.205.2:43892] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:05:17.589825 2017] [:error] [pid 1555] [client 185.188.205.2:45830] script '/var/www/html/xmlrpc.php' not found or unable to stat
    [Thu Jun 08 16:08:45.955502 2017] [mpm_prefork:notice] [pid 1525] AH00169: caught SIGTERM, shutting down
    [Thu Jun 08 16:08:47.058849 2017] [mpm_prefork:notice] [pid 2432] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
    [Thu Jun 08 16:08:47.058922 2017] [core:notice] [pid 2432] AH00094: Command line: '/usr/sbin/apache2'
    
    • @gpressutto5

      From what I can see there, you would be correct, though it's always a good idea to check the logs :-).

      With that out of the way, I would recommend checking your VirtualHost configuration as well as the URL that is setup in for WordPress.

      Your VirtualHost files are in this directory:

      /etc/apache2/sites-available
      

      If you could post the one that corresponds to your site, we can take a look at it.

      If you setup WordPress using the IP before the domain, it's also possible WordPress is using only the IP, thus you'd need to change the URL's that it uses.

      You can do that by opening wp-config.php and dropping in:

      define('WP_HOME','http://example.com');
      define('WP_SITEURL','http://example.com');
      

      Where http://example.com is your domain.

      You'd then refresh the page for the new URL to take. Since you're not able to access the domain, we'd need to check the configuration first.

      • I haven't installed wordpress yet. I've just rebuilded the droplet. All my settings are factory. When I use the IP Address I can see Wordpress Installation.

        On droplet:

        root@redefit:/etc/apache2/sites-available# ls
        000-default.conf  000-default.conf.dpkg-dist  default-ssl.conf
        root@redefit:/etc/apache2/sites-available# cat 000-default.conf
        <VirtualHost *:80>
                ServerAdmin webmaster@localhost
                DocumentRoot /var/www/html
        
                <Directory /var/www/html/>
                    Options FollowSymLinks
                    AllowOverride All
                    Require all granted
                </Directory>
        
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
        </VirtualHost>
        root@redefit:/etc/apache2/sites-available#
        

        On my local machine:

        ping redefit.com
        ping: cannot resolve redefit.com: Unknown host
        ping www.redefit.com
        ping: cannot resolve www.redefit.com: Unknown host
        
        • @gpressutto5

          On my end, testing the domain or IP results in the WordPress installation showing up as expected.

          Checking your DNS, the A entry is valid and confirmed to be working, though one issue with the www variant is that there's not an A or CNAME entry for it, so it will fail.

          You'd need to setup an A entry pointing www to the Droplet IP, or a CNAME that points www to redefit.com for www.redefit.com to work.

          ...

          In terms of configuration, if you want to specifically set the VirtualHost to use the domain, you could add:

          ServerName redefit.com
          ServerAlias www.redefit.com
          

          above:

          ServerAdmin webmaster@localhost
          

          and then restart Apache. This is a must if you plan on hosting multiple domains on the Droplet.

Have another answer? Share your knowledge.