3

I am running a web application on server. I did all the setups using Django & apache2. When I am running my application with the IP:PORT (x.x.x.x:9000) it works fine.

I tried to run the app with server ip & port, it works fine.

But I just want to run my application on IP only. May be I am wrong because i am newbie to django. If possible can some one give some ideas.

Shang Wang
  • 24,909
  • 20
  • 73
  • 94
parker
  • 41
  • 1
  • 2
  • 2
    Http request needs to access a service on your machine and the service needs a port. An IP only define which machine the service is running on, but you also need port to act as an endpoint to communicate. Please look at wikipedia for port definition. https://en.wikipedia.org/wiki/Port_(computer_networking) – Shang Wang Dec 17 '15 at 14:42
  • 1
    Please post your Apache config. – Alasdair Dec 17 '15 at 14:50
  • I highly suggest you use django + nginx + gunicorn. And use unix sockets NOT ports. I've used this setup time and time again, never fails. – Javier Buzzi Dec 17 '15 at 15:09
  • @ShangWang: That i know use of port for end point communication. For end user point of view i just want to do some thing so that user will access the application with out port for more easy access. I want to do some thing so that when user ll access application with IP only then server will listen on the default port(9000).Is there any way to do so? – parker Dec 17 '15 at 15:45
  • Default http port is 80 and default https port is 443. Check the wiki page in my earlier comment for reference. – Shang Wang Dec 17 '15 at 15:47
  • @ShangWang- Do u mean to say that in apache.conf i need to add the ports either 80 or 443 for default access? Is that right? – parker Dec 17 '15 at 15:53
  • Yes. If you use http put 80, if you use https put 443. – Shang Wang Dec 17 '15 at 16:04
  • @ShangWang-Thnx for more info – parker Dec 17 '15 at 16:54

3 Answers3

4

According to the discussion in the comment, sounds like you are confused about why do you need to explicitly specify the port. For http service the default port is 80, for https service, the default port is 443. When you are accessing the domain without the port, the request will by default try to hit either one depend on which method you use. You should on your apache setting specify the port to be 80 for http or 443 https. Hope that helps.

Shang Wang
  • 24,909
  • 20
  • 73
  • 94
  • I want to run my django application in web without port which is taking by default 8000. I am not talking about http or https requests. Can u give me some idea? – parker Dec 18 '15 at 05:26
  • Like if end user accessing a url. In that user is not giving any port right? Just giving IP or DNS. – parker Dec 18 '15 at 05:30
  • 1
    NO, when user visit a url, your browser would open up a TCP connection first, then send http request through the connection. Since django is hosted on a web server, which is apache in your case, the browser has to specify a port that it could connect to the web server. When you access `http://somesite.com`, it's the same as typing `http://somesite.com:80`. Please read some basic articles to learn more about this: http://www.jmarshall.com/easy/http/ – Shang Wang Dec 18 '15 at 14:32
  • And if you run the server on a different port, you have to specify the port when visiting url, because anything other than 80 is not default http://networkengineering.stackexchange.com/questions/1976/why-only-port-80-for-web-services. – Shang Wang Dec 18 '15 at 14:39
3

You can run the Django app without using the port as below.

Stop all the services that are running under port 80. Specify your IP address / your domain name in the settings file under

ALLOWED_HOSTS = ['IPadress/domainname']

Execute the following command

python manage.py runserver 0:80

Now run your application in the web browser as x.x.x.x (IP or domain name)

tuomastik
  • 4,559
  • 5
  • 36
  • 48
0

Stop all the services that are running under port 80

as tuomastik told, and maybe someone dont know how to do

How do I kill the process currently using a port on localhost in Windows?

remember to editting

> ALLOWED_HOSTS

in setting.py, as tuomastik told, and open port in firewall in server

> python manage.py runserver 0.0.0.0:80

but this

> For http service the default port is 80, for https service, the
> default port is 443

as Shang Wang told, is the most important (for me)

TarangP
  • 2,711
  • 5
  • 20
  • 41
lam vu Nguyen
  • 433
  • 4
  • 9