Https redirect doesn't work?

Posted September 9, 2020 2.7k views
WordPressLet's Encrypt

the site in question is:

I set up a marketplace Wordpress installation with let’s encrypt.

If I directly type in into my browser, it doesn’t connect and I get a timeout error.

If I type into my browser there are no issues.

Also, if I go to the non secure version of the site, it also gives me the timeout error.

I tried using the Really Simple SSL plugin in Wordpress for a 301 redirect, but that hasn’t helped. I also tried a redirect in the apache conf file for sites enabled, and that didn’t work either (though not 100% if I did it correctly).

What should I try next?

1 comment
  • FYI for others looking here we ended up with Dennis helping me set up the Wordpress installation for me from scratch on a Debian droplet, so you won’t find a direct answer looking through the comments.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers

Hey, @raimanau,

Could you post the content of your Apache/Nginx config:


Also, could you tell me how did you set-up your domain? Did you change the nameservers to match DigitalOcean ones? You should have the following records:

  • A record of pointing to droplet-ip
  • CNAME record of pointing to


  • Thanks Dennis! Yes definitely. And your questions are really on point and easy to understand! Thank you for that too!

    Regarding domain setup

    • Registered domains at and pointed Nameservers to Digital Ocean
    • Set up the domains on Digital Ocean and pointed them to the droplet IP
    • However I had two A records
    • (1) A record of pointing to the droplet-ip
    • (2) A record of pointing to the same droplet-ip
    • I just deleted (2) and set up a CNAME record of pointing to as you suggested

    As for the apache config in /etc/apache2/sites-enabled/anything-in-here

    There are two files: 000-default.conf and 000-default-le-ssl.conf

    This is the 000-default.conf content:

    # Added to mitigate CVE-2017-8295 vulnerability
    UseCanonicalName On
    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html
            <Directory /var/www/html/>
                Options FollowSymLinks
                AllowOverride All
                Require all granted
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    RewriteEngine on
    RewriteCond %{SERVER_NAME} [OR]
    RewriteCond %{SERVER_NAME}
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

    And this is the 000-default-le-ssl.conf content:

    <IfModule mod_ssl.c>
    <VirtualHost *:443>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html
            <Directory /var/www/html/>
                Options FollowSymLinks
                AllowOverride All
                Require all granted
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/
    SSLCertificateKeyFile /etc/letsencrypt/live/

    See anything I might be able to change?

    • Hey @raimanau,

      Hmm, everything looks to be clear. Could you post the .htaccess content under /var/www/html/.htaccess ? Also did you by chance changed stuff in /wp-admin?


      • Here’s what’s in .htaccess

        # BEGIN rlrssslReallySimpleSSL rsssl_version[3.3.5]
        <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTPS} !=on [NC]
        RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
        # END rlrssslReallySimpleSSL
        # BEGIN WordPress
        # "BEGIN WordPress" から "END WordPress" までのディレクティブ (行) は
        # 動的に生成され、WordPress フィルターによってのみ修正が可能です。
        # これらのマーカー間にあるディレクティブへのいかなる変更も上書きされてしまいます。
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
        # END WordPress

        I didn’t put anything in there manually, it was all automatically generated by Wordpress or the Really Simple SSL plugin. (And the comments are in Japanese because I’m setting up a Japanese site.)

        As for /wp-admin, I haven’t touched anything in terms of the files in that directly.

        I added couple of plugins to Wordpress, but otherwise I haven’t done much else. For reference, here they are:

        • Really Simple SSL
        • Better Search Replace (I used this to scan for instances of and replaced them with
        • Simple Slug Translate
        • WP Htaccess Editor

        That said, I should mention that I had issues accessing the site without https even before even logging into Wordpress.

        • Hi there @raimanau,

          Could you browse to your WordPress Settings -> General -> WordPress Address (URL) & Site Address (URL) and input in both fields?

          If that does not fix your issue, could you try moving the .htaccess to another directory (outside WordPress) and let me know what happens when you try to access the website?

          I hope we resolve this!


          • Yes! Thank you for working with me on this! I really appreciate it!

            I changed Settings -> General -> WordPress Address (URL) & Site Address (URL) and it didn’t fix the issue.

            Also moved the .htaccess to another directory and that didn’t work either :/

            I also remember one thing that might have caused the issue (but I don’t know how to fix it if that is the case).

            I set up the Wordpress on a droplet and with a temporary email, login, and password… but then I forgot what they were and couldn’t log in and I must have made a mistake with the email because I didn’t get an email when trying to reset my password.

            So I destroyed the droplet and recreated it.

            Before destroying the droplet I had no problems accessing the site via the domain, but after recreating it I’ve been having these problems.

  • Hi Dennis I couldn’t reply directly to the message since it was too deep in the thread?

    Anyways, I’m logged into root and tried the my mysql command and wasn’t able to get in. Here’s the message:

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
  • Just want to put a comment in here saying thank you Dennis for taking the time to set up the Wordpress and teaching me a few things as well! You are amazing!

Hey @raimanau,

Hmm, are you sure that your A record is pointing to your current IP? If that is the case, maybe delete and recreate the droplet again? As far as I can see, you haven’t started development yet, so this may be a good chance for us to experiment as much as possible.


  • Yes it’s pointing there! (And this is not my first time creating a Wordpress site on Digital Ocean so I’m pretty confident at least on that point)

    But I don’t mind deleting and recreating the droplet!

    How far should I go when recreating it?

  • Ok so I went through the steps to set up Wordpress via SSH.

    Some areas for reference

    Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    1: No redirect - Make no further changes to the webserver configuration.
    2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
    new sites, or if you're confident your site works on HTTPS. You can undo this
    change by editing your web server's configuration.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

    For this I chose “2”

    And then I also got some errors:

    Completing the configuration of WordPress.Error: Error establishing a database connection. This either means that the username and password information in your `wp-config.php` file is incorrect or we can’t contact the database server at `localhost`. This could mean your host’s database server is down.
    Error: Error establishing a database connection.
    Error: Error establishing a database connection.
    Installation complete. Access your new WordPress site in a browser to continue.

    This is the first time I’ve had this issue. What shall we do next?

Had same issue, spent lot of time looking for fix, installed plugins, etc.

Turned out official guide suggested optionally using ufw delete allow 80/tcp which was the cause of issue.

So i just had to ufw allow 80/tcp to make http version of my domain work again, which then automatically gets redirected to https, as supposed.