Server will not resolve web page via DNS

Brought up a new server. Put Ubuntu 20 on it. I installed Apache and set up a virtual-host name. (I've done this before on other Linode servers. I (kinda) know what I'm doing.)

At set an A record at the registry (PairDomains) pointing to the new IP. It has propagated at least to the Google DNS

If I key in just the IP into the browser the index.html test page resolves.

If I enter the domain, I get a message "Can't connect to the server."

This my first time with Ubuntu 20. Did I screw something up? HELP!


5 Replies

Your web server configuration is messed up or your firewall is blocking port 443. I'm betting on the latter…

stevewi:~ $ curl
<title>301 Moved Permanently</title>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="">here</a>.</p>
<address>Apache/2.4.41 (Ubuntu) Server at Port 80</address>

stevewi:~ $ curl
curl: (7) Failed to connect to port 443: Connection refused

Whitespace added for clarity.

-- sw

I thought about that but here is how ufw is configured:

zzzzz:/var/www/html/$ sudo ufw status
[sudo] password for xxx: 
Status: active 
To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere                  
80                         ALLOW       Anywhere                  
443                        ALLOW       Anywhere                  
22/tcp (v6)                ALLOW       Anywhere (v6)             
80 (v6)                    ALLOW       Anywhere (v6)             
443 (v6)                  ALLOW       Anywhere (v6)

Also, entering an http:// (no s) should resolve?

I added "Apache Full" to this as well but nothing changed. I then disabled the ufw and nothing changed. I even rebooted the server? UFW is not active:

[email protected]:/var/www/html$ sudo ufw status verbose
[sudo] password for xxx: 
Status: inactive

Your DNS changes have propagated to at least Seattle, WA:

stevewi:~ $ dig

; <<>> DiG 9.10.6 <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41944
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 1232
;            IN  A

;; ANSWER SECTION:        3285    IN  A

;; Query time: 30 msec
;; SERVER: 2607:f060:2::1#53(2607:f060:2::1)
;; WHEN: Mon May 03 17:43:38 PDT 2021
;; MSG SIZE  rcvd: 63

curl(1) fails on the IP address too:

stevewi:~ $ curl
curl: (7) Failed to connect to port 443: Connection refused

You might try this just for yucks:

sudo systemctl restart ufw

The next thing I would check is your SSL configuration in your web server…make sure your cert files are located where you told the web server they are.

-- sw

I got it to work!!! In the virtual-host record I took out this stuff:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted

RewriteEngine on
RewriteCond %{SERVER_NAME} [OR]
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

It works in my other domains but I think maybe I need to add an apache module for .htaccess to work… as this is what the above is for, from what I understand.

Thanks for your help.


Connection refused

This would indicate a service (Apache) not listening on port 443.

Ubuntu (via ufw) doesn’t respond to not-allowed ports so you would get a timeout if the port wasn’t allowed.

The fact @stevewi got a refusal suggests Apache wasn’t configured for port 443. The stuff you “took out” was the redirect from HTTP to HTTPS, so this wasn’t fixing the 443 problem, just stopping the server redirecting HTTP traffic to HTTPS.

However I can see this is now working (including HTTPS and the redirect) so I’m assuming you managed to get this configured successfully in the end. :)


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct