Pycharm + docker-compose, django server is not responding!

Answered

Everything runs fine, breakpoints run, debugger is connected, the runserver command runs properly and the server is started.

 

Whenever I send a request to that server though, there is server not found!

 

 

Recreating django_server ... 
Attaching to django_server
django_server | pydev debugger: starting
django_server |
Connected to pydev debugger (build 183.5429.31)
django_server | pydev debugger: New process is launching (breakpoints won't work in the new process).
django_server | pydev debugger: To debug that process please enable 'Attach to subprocess automatically while debugging?' option in the debugger settings.
django_server |
django_server | Performing system checks...
django_server |
django_server | System check identified no issues (0 silenced).
django_server | February 03, 2019 - 08:52:09
django_server | Django version 2.1.5, using settings 'config.settings'
django_server | Starting development server at http://0.0.0.0:8032/
django_server | Quit the server with CONTROL-C.

docker ps:

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                                         NAMES

34f7bd877cec        django_server           "python -u /opt/.pyc…"   5 minutes ago       Up 5 minutes        0.0.0.0:51150->51150/tcp, 52291/tcp, 0.0.0.0:8032->8000/tcp   django_server

 

The container has the open ports and everything should be fine, but it doesn't respond to any requests! When I run the docker-compose myself, it works well but no debugging offcourse!

11 comments

Hi,

Please elaborate on what do you mean by "server not found" ?

You're not getting a response on HTTP request? Is the execution paused on any breakpoint in that moment?

0

The request doesn't reach the server, host not found. like If I would access a server that does not exist

1

Please specify what kind of request are you taking about and how do you send it.

Is it working if you run the configuration without debugger from PyCharm?

0

Same issue here. I'm making a request from a browser to the django server running in the container. Tried both 127.0.0.1:8000 and 0.0.0.0:8000 to no avail. Both used to work in previous versions of pycharm. Mine also works if I run it from terminal with `docker-compose -f local.yml up`

0

@Isaac

So you are able to open http://0.0.0.0:8000/ in your browser but then you cannot make any requests?

0

Correct. For example, Firefox and cURL say they fail because “connection was reset”

0

Do you have the same problem if you start your Django server from the system terminal (outside of PyCharm) by running the same command PyCharm does?

0

When I run it from a terminal instead of a PyCharm run config, it connects and the site works. When using the run config, it won't connect.

0

Hmmm, that's odd.

There is probably something in run configuration that causing this since when you run the same command as PyCharm from the system terminal and it doesn't have this issue.

Does it work with our example from the documentation https://www.jetbrains.com/help/pycharm/using-docker-compose-as-a-remote-interpreter.html? There is a link to a project on GitHub.

I tried to reproduce on different OS, but it works fine.

0

Hi same error for me, I'm using Pycharm 2019.1. When I use command line my django app works fine, but not when I use pycharm. when I check the configuration. I see that Pycharm override my docker-compose configuration. If I check this config I see 

 

services:
web:
command:
- "/usr/bin/python3"
- "-u"
- "/opt/project/manage.py"
- "runserver"
- "8000"
environment:
PYTHONPATH: "/opt/project:/opt/.pycharm_helpers/pycharm_matplotlib_backend:/opt/.pycharm_helpers/pycharm_display"
DJANGO_SETTINGS_MODULE: "five_backend.settings.local"
PYTHONUNBUFFERED: "1"
PYTHONIOENCODING: "UTF-8"
PYCHARM_HOSTED: "1"
PYCHARM_DISPLAY_PORT: "62101"
stdin_open: true
volumes:
- "/Users/yavin4/dev/five-backend:/opt/project:rw"
- "pycharm_helpers_PY-191.6183.50:/opt/.pycharm_helpers"
working_dir: "/opt/project"
volumes:
pycharm_helpers_PY-191.6183.50: {}

 

the port 8000 is not shared. between the host and the container. and I cannot override this config. 

0

PyCharm just adds its own configuration file with needed settings, it doesn't overwrite your config(s).

Does it work with our example from the documentation https://www.jetbrains.com/help/pycharm/using-docker-compose-as-a-remote-interpreter.html? There is a link to a project on GitHub.

0

Please sign in to leave a comment.