# How to run django in EC2

**URL:** <https://forum.djangoproject.com/t/how-to-run-django-in-ec2/14885>\
**Category:** Deployment\
**Created:** [July 19, 2022, 10:07am UTC](https://forum.djangoproject.com/t/how-to-run-django-in-ec2/14885 "2022-07-19T10:07:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antony-M1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/antony-m1/32/8875_2.png) [@Antony-M1](https://forum.djangoproject.com/u/Antony-M1)\
**Post date:** [July 19, 2022, 10:07am UTC](https://forum.djangoproject.com/t/how-to-run-django-in-ec2/14885/1 "2022-07-19T10:07:45Z")

</div>

I have deployed the code in EC2 and the project was run in locally at 8000 port.  
but while i accessing the project using public port but it’s showing site can’t be reached

please help and thanks for advance

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 19, 2022, 10:27am UTC](https://forum.djangoproject.com/t/how-to-run-django-in-ec2/14885/2 "2022-07-19T10:27:37Z")

</div>

How are you running your code on the server?

Note: At a minimum, you will want to start with reading [How to deploy Django | Django documentation | Django](https://docs.djangoproject.com/en/4.0/howto/deployment/#how-to-deploy-django)

---

<div class="post-metadata">

**Author:** ![DanielGnzlzVll](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/danielgnzlzvll/32/4585_2.png) [@DanielGnzlzVll](https://forum.djangoproject.com/u/DanielGnzlzVll)\
**Post date:** [July 19, 2022, 12:03pm UTC](https://forum.djangoproject.com/t/how-to-run-django-in-ec2/14885/3 "2022-07-19T12:03:13Z")

</div>

Hi Anthony,

You need to edit your security groups by adding an inbount rule with your port. Additionally, depending on your operatic system you need to set properly your firewall.

---

<div class="post-metadata">

**Author:** ![Antony-M1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/antony-m1/32/8875_2.png) [@Antony-M1](https://forum.djangoproject.com/u/Antony-M1)\
**Post date:** [July 21, 2022, 9:34am UTC](https://forum.djangoproject.com/t/how-to-run-django-in-ec2/14885/4 "2022-07-21T09:34:48Z")

</div>

python manage.py makemigrations

python manage.py migrate

python manage.py collectstatic

python manage.py runserver 0.0.0.0:8000

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 21, 2022, 10:56am UTC](https://forum.djangoproject.com/t/how-to-run-django-in-ec2/14885/5 "2022-07-21T10:56:57Z")

</div>

> [@Antony-M1](#):
>
> python manage.py runserver 0.0.0.0:8000

This is an **extremely** bad idea for a public-facing instance of Django.

See [django-admin and manage.py | Django documentation | Django](https://docs.djangoproject.com/en/4.0/ref/django-admin/#runserver)

Quoting directly from the docs:

> **DO NOT USE THIS SERVER IN A PRODUCTION SETTING.**
