0

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.

Community
  • 1
  • 1
Ness
  • 1,415
  • 1
  • 13
  • 19
  • Have you tried visiting the site on the Windows machine using one of the IP's from the list along with your port? edit: To clarify, I mean without using PuTTY and simply navigating to the site on the Windows machine. – ztindall Sep 05 '19 at 17:30
  • There is no web address as far as I am aware. And everything I try that might work simply doesn't. – Ness Sep 05 '19 at 17:50
  • Is that port visible to your Windows machine? You can possible run (via PowerShell v4 or above) `Test-NetConnection -port ` and see if it sees the address and port. I do not know your specific situation but it sounds like some sort of issue with your network setup? For instance, I cannot access my site using the IP address, I have to use our in-house resolved address. I hope this helps! – ztindall Sep 05 '19 at 19:28
  • 1
    Regarding the "on hold" status, this question is entirely within the range of questions to ask on this website. Just look in the help center: "software tools commonly used by programmers". Everything I mentioned in my question falls under that category. PuTTY, Python, and Django are programmers' tools. Look at Super User's help: "general computing hardware and software". This question has nothing to do with "general" anything. – Ness Sep 09 '19 at 17:37
  • How do you then troubleshoot it? Or is it when you see the website is down then you restart the server? By running the manage.py command on terminal? – Denise May 19 '20 at 17:07

2 Answers2

3

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:

  • source = 8000
  • destination = 0.0.0.0:8000

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...

Ness
  • 1,415
  • 1
  • 13
  • 19
0

This applies to RHEL 7.* or CentOS if you are running on that Linux distribution:

Have you tried turning off your firewalld to test and see whether you can access the Django through the browser? If you haven't already, just see if the firewall status is active by typing sudo firewall-cmd --state and then turn off by sudo systemctl stop firewalld

Try testing to see whether you access it by the [external IPv4]:8000 If you can, then we're getting somewhere.

Turn firewalld on sudo service firewalld start and allow http service through the firewall with the following command firewall-cmd --permanent --add-service=http

Finally, reload the firewall firewall-cmd --reload

Hopefully, that should work.