Pycharm + docker-compose, django server is not responding!
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!
Please sign in to leave a comment.
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?
The request doesn't reach the server, host not found. like If I would access a server that does not exist
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?
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`
@Isaac
So you are able to open http://0.0.0.0:8000/ in your browser but then you cannot make any requests?
Correct. For example, Firefox and cURL say they fail because “connection was reset”
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?
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.
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.
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.
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.
I had the same problem, using the default Django Server run configuration with the Docker Compose interpreter selected.
It turns out that you must specify 0.0.0.0 in the "Host" field of the server run configuration. (This field is blank by default.) Once that is specified, and the server restarted if necessary, you will be able to access the server running in the Docker container at 127.0.0.0:8000 (assuming you're using the default 8000 port).
If you are using Django, it's important to add:
in Parameters field of Run/Debug configuration dialog.
If Anyone came here from Following this Guide: https://www.jetbrains.com/help/pycharm/using-docker-compose-as-a-remote-interpreter.html?_ga=2.251633153.645674516.1589467895-593042553.1588614408
At the Time of Writing I am Using
I had struggled with an issue to set this up on a project that wasn't owned by me. The example they give is if you have the internal docker port matching the external.
In order to have this work with a different internal port, for example
Notice the 5000
Notice
If you are requiring any help you can reach me at here
I had the same issue and I solved it by setting the host in the run config from 127.0.0.1 to 0.0.0.0. Maybe this helps some others stumbling over this post.