1

I am running a Django server on a redhat computer. I can remotely connect to the computer via ssh connection, so I am assuming there is no firewall issue. However, when I execute the following command (which supposedly should make the server publicly available)

python3 manage.py runserver 0.0.0.0:8080

The server is not reachable from any other computer. Locally (from the redhat machine itself) I can see the server is running.

I am new to redhat, so if there is any other information I should provide, please let me know.

So far, I have found that I can make my server reachable using localtunnel, however, since it changes the url, I prefer to solve the issue some other way.



UPDATE: the problem had nothing to do with Django. What made confusion was that the server was running with no problem and turned unreachable with no specific reason.

Anyways, I needed to add some configurations (found in here) to make port:8080 reachable.

Community
  • 1
  • 1
Matin Kh
  • 5,192
  • 6
  • 53
  • 77
  • Try `netstat -tanp | grep LISTEN` to see if the port is listening to the network and `iptables -L` to make sure there are no firewall rules that forbids it. – Davor Lucic Jun 12 '16 at 18:28
  • Tried the first command and it seems that the port is listening. I am not sure how to interpret the second command's output, so I provide you the output log: https://www.dropbox.com/s/zoul6y8dag04h74/iptables.txt?dl=0 – Matin Kh Jun 12 '16 at 18:35
  • Hmm, quite complex rules, latest RedHat seems to use firewalld instead of iptable so I cant say much. There is a rule down at the bottom `dpt:ssh ctstate NEW` which allows for new ssh connections, and `ACCEPT all -- anywhere anywhere` at the top is probably for `lo` interface so I am pretty sure that its blocking incoming connection to your Django port. Can you run `iptables -vL`, it will clear up the ACCEPT all rule since it will show the interface. I am not sure what is the best way to open the port on firewalld unfortunately. – Davor Lucic Jun 12 '16 at 18:51
  • 1
    `firewall-cmd --zone=public --add-port=8080/tcp` something like this I assume but do take this with a grain of salt. I am not RH sys-admin. – Davor Lucic Jun 12 '16 at 18:53
  • 1
    Possible duplicate of [centos 7 - open firewall port](http://stackoverflow.com/questions/24729024/centos-7-open-firewall-port) – Matin Kh Jun 16 '16 at 14:02
  • @DavorLucic last comment is the answer; details: (1) go to `/usr/bin` directory (as root) and execute: (2) `firewall-cmd --zone=public --add-port=8080/tcp` – Matin Kh Jun 16 '16 at 14:07
  • Martin, it looks like you are trying to expose an application to the web so I would ask the server admin first if it is necessary to have a security review. If the server is restricted to campus-only users, then it should be a matter of just changing the firewall rules as other users mentioned above. – Andrei Sura Jun 16 '16 at 14:08
  • @AndreiSura I understand the concern, but I am _everyone_ in this project (server admin, developer, tester, data analyst, ...) so I took it upon myself to find a solution _as quick as possible_, giving less priority to security issues. – Matin Kh Jun 16 '16 at 14:13
  • being admin/tester/da is fun :) – Andrei Sura Jun 16 '16 at 15:08

1 Answers1

0

Open the port 8080 with

firewall-cmd --zone=public --add-port=8080/tcp

To add it permanently to the system, add --permanent like so:

firewall-cmd --zone=public --add-port=8080/tcp --permanent