Lightsail Django demo app 404 Bad request after setting static IP

0

Hi, I’m hosting a demo Django application on an AWS Lightsail instance. It was working correctly at the original assigned IP address, but the documentation recommended adding a static IP address, which I did (it’s 50.112.67.77). I can SSH into the instance using that IP, and the ipv4 firewall rules are set to allow HTTP on port 80 and HTTPS on 443.

But since making that change, I keep getting 400 Bad Request when I try to access the Djang site from a browser. I first tried setting ALLOWED_HOSTS=[‘50.112.67.77’]. When that didn’t work, I tried temporarily setting ALLOWED_HOSTS=[‘*’] and DEBUG=True, but still am getting 400 Bad Request.

I can still use manage.py runserver to run the app while in an SSH session and access the app in a second SSH session using lynx http://127.0.0.1:8000. When I do that, I see the expected ‘hello world’ http response.

I’d appreciate any help in how to troubleshoot this.

Thanks!

1 Answer
0
Accepted Answer

It started working after I added a letsencrypt cert and restarted services sudo /opt/bitnami/ctlscript.sh restart. I think the issue with 400 Bad request would have been solved by just restarting services.

answered a year ago
  • That is correct. After attaching a Static IP, rebooting the instance or restarting the bitnami services helps update the application config that uses/needs the instance's public IP.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions