Cannot runserver from Pycharm using Vagrant Interpreter. Path for is wrong, don't know where to fix it

I'm trying to configure correctly Pycharm (for a Django project) + Vagrant, to launch the runserver remotely from my host machine (and thus enable debugging).

The command for such seems simple but the path is wrong, so it fails. It tries to run /home/vagrant/.virtualenvs/[myprojname]/bin/python /vagrant/[myprojname]/ runserver

Second parameter is wrong, it's missing either the initial /home/ or it isn' a relative path.

My run configuration

I'm running a host windows machine, and a vagrant ubuntu 20.10 guest VB. I setup my remote interpreter with what I suppose are the right parameters.

In my vagrantfile I have setup the shared folder as following (Project name is PoeMogul) config.vm.synced_folder "PoeMogul", "/home/vagrant/PoeMogul"

  • In my vagrant box, everything is setup fine (I think). I have my venv. In my /home/vagrant/PoeMogul dir i can see my working directory from PyCharm. I can manually (through vagrant ssh) run the server. But i cannot make Pycharm invoke the file correctly, it tries to access "/vagrant/..." and not "/home/vagrant/...".

To resolve the issue with the incorrect path in PyCharm, you should specify the correct path to the Python interpreter and the Django project in the Run Configuration.

In PyCharm, go to Run > Edit Configurations.

Click the plus sign (+) to create a new configuration, and select Django Server.

Give the configuration a name, such as "Vagrant Django Server".

In the Environment section, select the remote interpreter that you set up for your Vagrant virtual machine.

In the Host field, enter the IP address of the Vagrant machine,

In the Port field, enter 8000.

In the Working directory field, enter the absolute path to your Django project in the Vagrant virtual machine, e.g. /home/vagrant/PoeMogul.

In the script field, enter the absolute path to the file in the Django project, e.g. /home/vagrant/PoeMogul/

Click Apply and then OK to save the changes.

Now, when you run the Vagrant Django Server configuration in PyCharm, it should use the correct paths and start the Django development server on your Vagrant virtual machine, accessible at from your host machine.

Back to Top