skip to Main Content

Error:
DisallowedHost at /
Invalid HTTP_HOST header: ‘3.17.142.65’. You may need to add ‘3.17.142.65’ to ALLOWED_HOSTS.

I am trying to deploy my django site om AWS EC2 while deploying through github using git clone on AWS live cli. I am getting the following errors again and again. My EC2 instance ip is 3.17.142.65 and in my settings file first i kept it like this ALLOWED_HOSTS = ['3.17.142.65', 'localhost', '127.0.0.1'] this shows me the same error then i changed it to ALLOWED_HOSTS = ['3.17.142.65']
this also giving same error. (One thing i am not getting like i cloned my github project once at starting after then if i am changing on my github setting file how aws cli knows these changes. Btw i run the command git pull origin master Am i right that i should run this command while making any changes on github files? )

I am new to ubuntu and deploying websites so please guide me what mistake i am dong here.

To run the server i executing these commands

sudo systemctl restart nginx
sudo service gunicorn restart
sudo service nginx restart

My Configured Nginx file

server {
    listen 80;
    server_name 3.17.142.65;

    location = /favicon.ico { access_log off; log_not_found off; }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}

2

Answers


  1. Chosen as BEST ANSWER

    I just executed these commands to tell EC2 server, the changes which i made on github files

    git fetch --all
    git reset --hard origin/master
    

  2. use ALLOWED_HOSTS = [‘*’] its automatically allowed all host ip

    are you open port on ec2 ?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search