简体   繁体   中英

Django centos server not receiving requests

I just deployed my Django project to a local CentOS server for testing. The problem is that after I run my server like: 192.168.1.4 (server ip), and run in port:3001 and then I send a request from another computer on the same LAN this requests are not being received by the server.

Local request from the server to the server are working fine.

Also:

   ALLOWED_HOSTS = ['*']
   CORS_ORIGIN_ALLOW_ALL = True
   CORS_ALLOW_CREDENTIALS = True

Django: 2.1 CentOs: 7

The command netstat shows that indeed the port is listening. The port has already been opened in the router.

Even when netstat showed that the port was open, it was closed in the server. I managed t open it with the following command:

sudo firewall-cmd --zone=public --add-port=3001/tcp --permanent
sudo firewall-cmd –reload

I hope this helps anyone else having similar issues.

The default IP address, 127.0.0.1, is not accessible from other machines on your network.

To access your machine from other machines on the network, use its own IP address 192.168.1.4 or 0.0.0.0.

python manage.py runserver 0.0.0.0:8000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM