# Cannot use runserver, but http.server works

**URL:** <https://forum.djangoproject.com/t/cannot-use-runserver-but-http-server-works/7603>\
**Category:** Using Django\
**Created:** [April 20, 2021, 6:47pm UTC](https://forum.djangoproject.com/t/cannot-use-runserver-but-http-server-works/7603 "2021-04-20T18:47:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobort](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/bobort/32/3043_2.png) [@bobort](https://forum.djangoproject.com/u/bobort)\
**Post date:** [April 20, 2021, 6:47pm UTC](https://forum.djangoproject.com/t/cannot-use-runserver-but-http-server-works/7603/1 "2021-04-20T18:47:15Z")

</div>

This is the strangest thing. Whenever I use the `runserver` command, I get this error message:  
`Error: You don't have permission to access that port.`

The same thing happens no matter what port I designate, whether it’s `8000` or `8001` or `8002`.

Here’s the kicker:  
When I run the Python `http.server` on those very same ports, I get no error, and the Python server runs.

My project used an older minor version of Python and Django before I upgraded, but I’m at a loss as to continue how to troubleshoot this issue.

---

<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:** [April 20, 2021, 7:15pm UTC](https://forum.djangoproject.com/t/cannot-use-runserver-but-http-server-works/7603/2 "2021-04-20T19:15:27Z")

</div>

Interesting. Can you post the complete runserver command you’re using, along with the version of Django and the operating system you’re running this on?

The error message you’re referencing comes from [django/runserver.py at 54e94640ace261b14cf8cdb1fae3dc6f068a5f87 · django/django · GitHub](https://github.com/django/django/blob/54e94640ace261b14cf8cdb1fae3dc6f068a5f87/django/core/management/commands/runserver.py#L149)  
(Or the corresponding line of code depending upon the version you’re using.)

That try block calls `get_handler` and `run` - either of which _could_ throw this error.

If I had to diagnose something like this, I’d be tempted to do one (or both) of:

- Edit the runserver command to print the complete error and traceback to see if there’s more information.
- Try the runserver\_plus command from [django-extensions](https://django-extensions.readthedocs.io/en/latest/) (which is a “must have” in my projects _anyway_.)

---

<div class="post-metadata">

**Author:** ![bobort](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/bobort/32/3043_2.png) [@bobort](https://forum.djangoproject.com/u/bobort)\
**Post date:** [April 21, 2021, 3:37pm UTC](https://forum.djangoproject.com/t/cannot-use-runserver-but-http-server-works/7603/3 "2021-04-21T15:37:38Z")

</div>

I’ll continue to troubleshoot based on your advice. This is the command I’m running by default:

`manage runserver`

Using Windows 10, Django 3.2, and Python 3.9.4.

I was able to use `runserver_plus`, and I was able to run the server just fine. However, I received this output:

```
Error occurred during checks: PermissionError(13, 'Permission denied')

 * Restarting with windowsapi reloader
Performing system checks...

System check identified no issues (0 silenced).
Error occurred during checks: PermissionError(13, 'Permission denied')

Django version 3.2, using settings 'myproject.settings.dev'
Development server is running at http://[127.0.0.1]:8000/
Using the Werkzeug debugger (http://werkzeug.pocoo.org/)
Quit the server with CTRL-BREAK.
 * Debugger is active!
 * Debugger PIN: ***
 * Running on http://127.0.0.1:8000/ (Press CTRL+C to quit)

```

I ran `manage check`, and the system didn’t find any other errors.

The error seems to be related to file permissions. I did reset all the file permissions, but continue to receive the same error. I just read that Python could be confusing a folder as a file in Windows, and that would cause the problem. I’m now trying to figure out what folder that could be in my project.

I’m continuing to troubleshoot.

---

<div class="post-metadata">

**Author:** ![bobort](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/bobort/32/3043_2.png) [@bobort](https://forum.djangoproject.com/u/bobort)\
**Post date:** [April 21, 2021, 4:23pm UTC](https://forum.djangoproject.com/t/cannot-use-runserver-but-http-server-works/7603/4 "2021-04-21T16:23:51Z")

</div>

I added a print statement to `check_errors` function in the `runserver_plus` command to show the files that have exceptions. It seems like a handy tool to add to the output anyway. Regardless, I discovered that the `check_errors` function is checking a file that simply doesn’t exist within the virtual environment. Now, it turns out, that I’m using a git repository, and the path to that file does exist on a different computer (path to the `activate_this.py` script), but not the one I’m developing on currently. I just tried re-creating the virtual environment, but I’m getting the same issue. I’m interested in other ideas. There is no reference to this file anywhere in the project.

---

<div class="post-metadata">

**Author:** ![bobort](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/bobort/32/3043_2.png) [@bobort](https://forum.djangoproject.com/u/bobort)\
**Post date:** [April 22, 2021, 6:41pm UTC](https://forum.djangoproject.com/t/cannot-use-runserver-but-http-server-works/7603/5 "2021-04-22T18:41:14Z")

</div>

I found the issue, and it is quite embarrassing. Apparently, many years ago on this particular project, I edited the `wsgi.py` file. I think I had edited it to take advantage of `waitress`. I had since returned to using Apache, but I never changed the `wsgi` file after that. Truth be told, I use neither `waitress` nor Apache during development; I think I was just doing a test with it. Honestly, I don’t remember why I modified that file, but I had hard-coded the path to the virtual environment on the modular level without any exception handling.

Upon commenting it, everything worked fine. I would have never been able to do this without your help, though. Thank you so much!
