skip to Main Content

I’m running an EC2 instance on AWS. I’m running apache out of the standard port 80 without issues, and I have an node.js/Express application running out of port 3000 without issue. I’m trying to open up port 8000 on the machine and I’m not able to connect. I’m attempting to run a Django project from 8000. Locally, on my machine, I’m able to run the Django project. When I use the curl command locally, I get data back:
curl localhost:8000

That returns a valid HTML page. When I use the netstat command, it shows that port 8000 is being listened to. If I open a new window and attempt to start Django again when the first one is running, I get an error that port 8000 is already in use. So, it looks like things are running properly on the local machine.

So that leads me to believe that there is something incorrect with my AWS set up. However, I set up the ports the same way for 8000 as I did for 3000. Here is a screen shot of the Inbound rules:
enter image description here

I did set up port 3000 over 2 years ago, so it’s possible I’m missing a step, but everything looks right from what I can remember.

2

Answers


  1. Chosen as BEST ANSWER

    Thanks for all the help. I needed to make two changes:

    1. I needed to change how I invoked the Django run time environment. I had used python manage.py runserver and needed to tack on 0.0.0.0:8000 to make it work: python manage.py runserver python manage.py runserver
    2. Needed to add the DNS name to allowed hosts

  2. If you set DEBUG = True and ALLOWED_HOSTS = [] in settings.py, the host is validated against the list ['.localhost', '127.0.0.1', '[::1]'] which your EC2 deployment does not meet.

    Also note, that you should not use the above settings in production.

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