0

This question is very similar to (but is not the same because I am running on the google cloud, which I suspect may be cause of the issue):

I am trying to set up an api running on a VM-instance on the google cloud platform. So far I got nginx working (when I go to the ip address it greats me with a welcome message). When I run:

python3 manage.py runserver 0.0.0.0:8000

I get the following output:

Performing system checks...

System check identified no issues (0 silenced).

February 06, 2019 - 09:27:13

Django version 2.1.5, using settings 'my_api.settings.development'

Starting development server at http://0.0.0.0:8000/

Quit the server with CONTROL-C.

Which seems good, but when I go to any of the following pages (all of which I've listed under allowed_hosts):

  • 0.0.0.0:8000
  • 127.0.0.1:8000
  • < my ip address>:8000

The page won't load.

I´ve tried checking which ports are used using

netstat

And I've killed all programs using this port after which I restarted my program, but to no avail.

At this point, I've fixed everything suggested in other posts and I'm out of ideas. What would be the next step in finding/solving the cause of my internet page not loading?

Community
  • 1
  • 1
Nathan
  • 3,558
  • 1
  • 18
  • 38
  • Did you open a firewall port for 8000? Where are you checking the ip addresses from? The address `0.0.0.0` is not a valid address to try to connect to. `127.0.0.1` is only valid from inside the VM. – John Hanley Feb 06 '19 at 09:48
  • @JohnHanley I did not, I am checking them from my own computer which could explain why they don't work. I'll have a look, thanks – Nathan Feb 06 '19 at 09:51
  • @JohnHanley it was indeed a firewall port. If you post it as an answer I'll accept it. Otherwise I'll write it myself – Nathan Feb 06 '19 at 10:04

3 Answers3

5

You will need to create a firewall rule to allow inbound traffic on tcp port 8000.

When creating the firewall rule, also specify a Target tag so that you can assign the firewall rule to the instance. Another option is to specify a service account such as Compute Engine default service account to assign the rule based upon identity.

Filtering by service account vs. network tag

John Hanley
  • 74,467
  • 6
  • 95
  • 159
0

As @JohnHanley points out, I needed to create a firewall rule.

I did this by:

  1. going to the google cloud platform console
  2. firewall rules -> vpc network
  3. + create firewall rule
  4. Added all necessary ip addresses to the "source ip ranges" (followed with /32, not sure why, but this is what seems to work)
  5. Under "Protocols and ports", I added tcp: 8000
  6. I applied this to my server
Nathan
  • 3,558
  • 1
  • 18
  • 38
0
  1. Make sure http traffic is enabled

  2. Make a firewall rule like so:

enter image description here

Taimoor Ahmad
  • 530
  • 5
  • 11