Digitalconqurer.com articles may affiliate links and is a member of the Amazon Services LLC Associates Program and a few other affiliate programs. If you make a purchase using one of these affiliate links, we may receive compensation at no extra cost to you. See our Disclosure Policy for more information.

 

How to Fix Ghost Redirecting to Localhost (127.0.0.1:2368) on AWS Lightsail

If your self-hosted Ghost blog keeps redirecting to https://127.0.0.1:2368 instead of your actual domain, this guide will help you troubleshoot and fix the issue. This is quite common with Bitnami Ghost setups on AWS Lightsail when reverse proxy isn’t configured properly.


Step 1: Update config.production.json

  1. SSH into your server
    ssh bitnami@your-server-ip

        or use lightsail’s connect option directly.

  1. Open the config file
    sudo nano /opt/bitnami/ghost/config.production.json
  2. Edit the URL field:
    "url": "https://your-domain.com"
    

    Important: Do not use localhost or 127.0.0.1!

  3. Save and exit (Ctrl+O then Ctrl+X).

Step 2: Fix Apache Reverse Proxy (VHost)

  1. Edit the Apache vhost config
    sudo nano /opt/bitnami/apache2/conf/vhosts/ghost-https-vhost.conf
  2. Use this configuration block:
    <VirtualHost 127.0.0.1:443 _default_:443>
      ServerName your-domain.com
      ServerAlias www.your-domain.com
      SSLEngine on
      SSLCertificateFile "https://digitalconqueror.b-cdn.net/opt/bitnami/apache/conf/your-domain.com.crt"
      SSLCertificateKeyFile "https://digitalconqueror.b-cdn.net/opt/bitnami/apache/conf/your-domain.com.key"
    
      ProxyPreserveHost On
      RequestHeader set X-Forwarded-Proto "https"
    
      ProxyPass /.well-known !
      ProxyPass / http://127.0.0.1:2368/
      ProxyPassReverse / http://127.0.0.1:2368/
    </VirtualHost>
    
  3. Save and exit.

Step 3: Check mod_headers (Required for Proxy Headers)

  1. sudo /opt/bitnami/apache2/bin/apachectl -M | grep headers
  2. If nothing shows, edit:
    sudo nano /opt/bitnami/apache2/conf/httpd.conf

    and make sure this line is uncommented:
    LoadModule headers_module modules/mod_headers.so

Step 4: Test Configuration

sudo /opt/bitnami/apache2/bin/apachectl configtest

If it says Syntax OK, proceed!


Step 5: Restart Services

sudo /opt/bitnami/ctlscript.sh restart ghost
sudo /opt/bitnami/ctlscript.sh restart apache

Step 6: Clear Browser Cookies & Cache

  • Delete cookies for your site (Settings > Privacy > Cookies)
  • Try in Incognito mode for fresh session

Troubleshooting Common Errors

ERR_TOO_MANY_REDIRECTS
  • Add RequestHeader set X-Forwarded-Proto "https" to Apache config
ERR_CONNECTION_REFUSED
  • Run sudo /opt/bitnami/apache2/bin/apachectl configtest and fix any syntax errors shown
EACCES: permission denied
  • Use sudo or fix file ownership:
    sudo chown -R ghost:ghost /opt/bitnami/ghost

Verification Checklist

  • Visit https://your-domain.com (should load, not redirect)
  • Ghost admin panel at https://your-domain.com/ghost works
  • No redirects to localhost

Why This Happens

Ghost sees requests as HTTP unless proxy headers are set. The solution is correct headers + correct config file.


Conclusion

Combine a valid config.production.json and proper proxy headers in Apache, restart services, and your Ghost site will work perfectly with your custom domain.