Django application hosted in vagrant not available at localhost

12 Views Asked by At

I have the Vagrant configuration that used to work some time ago, but now the application is not available at localhost after starting in virtual machine.

Vagrant file content:

# -*- mode: ruby -*-
# vi: set ft=ruby :
ENV["LC_ALL"] = "en_US.UTF-8"
ENV["VAGRANT_DETECTED_OS"] = ENV["VAGRANT_DETECTED_OS"].to_s + " cygwin"

Vagrant.configure("2") do |config|

  config.vm.box = "generic/rocky8"

  config.vm.network "forwarded_port", guest: 8080, host: 1234

  config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__auto: true

  config.vm.provider "virtualbox" do |vb|
     vb.memory = "1024"
  end

  if Vagrant.has_plugin?("vagrant-vbguest")
    config.vbguest.auto_update = false
    config.vbguest.no_remote = true
  end

end

Django application is started using following command python manage.py runserver 0.0.0.0:8080

When running curl http://0.0.0.0:8080 in the Vagrant machine it returns expected result and Django logs "GET / HTTP/1.1" 200 20766, while in the host machine:

curl http://127.0.0.1:1234
curl: (56) Recv failure: Connection was reset

Also, web browsers fail to connect returning either ERR_CONNECTION_RESET or ERR_INVALID_HTTP_RESPONSE.

Additional thing I checked:

vagrant port
The forwarded ports for the machine are listed below. Please note that
these values may differ from values configured in the Vagrantfile if the
provider supports automatic port collision detection and resolution.

    22 (guest) => 2222 (host)
  8080 (guest) => 1234 (host)

I am on Windows 11 and tried a lot of different configurations, even installing the same in another computer (Mac) but still experiencing the same challenge. Also asked ChatGPT to help me analyze the vagrant file and other config but none of the suggestions were helpful to move forward.

I will be grateful for any lights!

0

There are 0 best solutions below