I've looked and tried things for hours, and nothing seems to work. Here's the info:
On my Windows machine, I use PuTTY or MobaXterm to connect to a remote Linux server using SSH (command line only).
I started a new project with this command: django-admin startproject mysite
.
I activate a virtual environment using the source
command.
I run the server using this command: python3 manage.py runserver 0.0.0.0:8000
.
Let's say the output of ip a
results in the following fake IP addresses:
1: inet 127.0.0.1/8 scope host lo
2: inet 172.10.12.50/24 brd 172.10.12.200 scope global ens3
3: inet 62.3.8.10/26 brd 62.3.8.22 scope global ens4
Now what? I can't figure out how to visit the website. I've tried the various IP addresses, I've tried using PuTTY's tunneling/port forwarding capabilities, I've tried figuring out MobaXterm's tunneling/port forwarding capabilities, and I think I've tried every possible combination of IP addresses in those settings. Nothing works.
I am supposedly able to access the site using http://127.0.0.1:8000 when the port forwarding works correctly, but that hasn't happened yet. I have also tried using the other IP addresses from the ip a
command.
We finally figured it out. The problem was using a jump server. I was logging into serverA first, and then using ssh to log into serverB where the project was. We do this because we cannot access serverB without first going to serverA. (I have no idea why.)
So the settings I used in PuTTY, Connection > SSH > Tunnels were:
And then after I logged into serverA, I used the following command to log into serverB:
$ ssh serverB -L8000:0.0.0.0:8000
Then I ran the source command for the virtual environment, then the runserver command:
$ python3 manage.py runserver 0.0.0.0:8000
And then I was able to access the website on my local machine via http://127.0.0.1:8000
Now to figure this out in MobaXterm since that is my preferred SSH client...