0

I can’t seem to run Django on CS50 IDE. I downloaded Django without a problem. I can create a Django app without a problem using "python manage.py startapp hello". But the problem comes when I run "python manage.py runserver". The result is:

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
January 23, 2021 - 10:17:21
Django version 3.1.5, using settings 'wiki.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

The link http://127.0.0.1:8000/ leads me to a page which says:

This site can’t be reached127.0.0.1 refused to connect.
Try:

Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED

So I ran 'python manage.py migrate'. The result was:

Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sessions.0001_initial... OK
~/wiki/ $ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
January 23, 2021 - 10:20:51
Django version 3.1.5, using settings 'wiki.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

When I go to the link "http://127.0.0.1:8000/", the result in the browser was:

This site can’t be reached127.0.0.1 refused to connect.
Try:

Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
2
  • Try changing the allowed_hosts variable in settings.py file like this ALLOWED_HOSTS= ['127.0.0.1']. This worked for me.
    – Ananth
    Commented Jan 23, 2021 at 10:47
  • It doesn't seem to be working for me:( Thanks anyways Commented Jan 23, 2021 at 13:25

1 Answer 1

4

Type python manage.py runserver 0.0.0.0:8080 and start the server. Then click the web server option in the IDE. After going to the site, remove the -beta from the url and press enter. It will show disallowed host. So now add the url to the allowed hosts like this ["{{the url you got}}", '0.0.0.0']. Then wait for the server to reload or restart the server. Go to the new url. This will now work. This is the official method to run Django on CS50 IDE.

Hope this helps. If it does, then please check the tickmark.

14
  • When I type "python manage.py runserver 0.0.0.0:8080", and go to the site, I don't see -beta in the url. Instead my url is ide-c256bcd642754f9c9c11ba531cd396c6:8080 The error message in the browser is This site can’t be reachedCheck if there is a typo in ide-c256bcd642754f9c9c11ba531cd396c6. If spelling is correct, try running Windows Network Diagnostics. DNS_PROBE_FINISHED_NXDOMAIN Commented Jan 23, 2021 at 13:07
  • It should be ide-c256bcd642754f9c9c11ba531cd396c6-8080.cs50.xyz
    – Vsjain
    Commented Jan 23, 2021 at 13:10
  • But it isn't. And I can't seem to get the .cs50.xyz behind. Anyways, what did you mean by remove the -beta from the url? Even with the url you wrote I don't see the -beta Commented Jan 23, 2021 at 13:13
  • Try using the url I have posted. That should work
    – Vsjain
    Commented Jan 23, 2021 at 13:16
  • Ok I tried to add .cs50.xyz behind my url and it still doesn't seem to be working. For the allowed hosts line of code, is it supposed to look like that? ALLOWED_HOSTS = ["{{ide-c256bcd642754f9c9c11ba531cd396c6-8080.cs50.xyz}}", '0.0.0.0'] Commented Jan 23, 2021 at 13:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .