Development Server Ignores IP-address Parameter

32 views
Skip to first unread message

tdtho...@gmail.com

unread,
Jul 15, 2015, 10:07:11 PM7/15/15
to django...@googlegroups.com
For some reason, my Django Development Server ignores the IP:Port parameter when I start it. No matter what I enter for that parameter, it always uses 127.0.0.1:8000.  I think (but am not sure) this started happening when I upgraded from Django-1.7 to Django-1.8.2.

I am running on Slackware Linux, I have not noticed this problem until
recently.  It definitely worked correctly several months ago.

At the bottom of this message, I show how I launch the server,
and the response it gives in my console. No matter what IP:Port
I request, I always get 127.0.0.1:8000.

How can I fix this problem?

Thanks.
------------------------
I start the development server with the following command:

  % python  manage.py runserver  192.168.0.102:8001

The following reply appears on the console:

  /usr/local/lib/python3.3/importlib/_bootstrap.py:313: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
  return f(*args, **kwds)

  Performing system checks...

  System check identified no issues (0 silenced).
  July 15, 2015 - 17:45:10
  Django version 1.8.2, using settings 'app3.settings'
  Starting development server at http://127.0.0.1:8000/
  Quit the server with CONTROL-C.


Sadaf Noor

unread,
Jul 16, 2015, 5:13:35 AM7/16/15
to django...@googlegroups.com
Actually if you run your django at 0.0.0.0:8000 at your server pc which has a ip 192.168.0.102 
./manage.py runserver 0.0.0.0:8000

then from another pc of the same network (as 192.168.0.102 is a local ip) if you type http://192.168.0.102  then it will show your desired website.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a695a746-618a-46a2-a216-180577e829ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
 Md. Sadaf Noor (@sadaf2605)
 www.sadafnoor.com

tdtho...@gmail.com

unread,
Jul 16, 2015, 2:26:21 PM7/16/15
to django...@googlegroups.com
Sadaf,

Thanks for your reply.  To be clear, my objective is to run tests with other computers behind my firewall.  Hence the 192.168.0.102 address which will only work on my local network.

I tried your idea of specifying 0.0.0.0:8000, but that did not work.  The development server still runs with 127.0.0.1:8000.

The django documentation in the section, "django-admin and manage.py" indicates that:


  python manage.py runserver 192.168.0.102:8001

should work, but it does not.  It did work for me earlier on the
same machine using Django 1.7.

Thanks.

John 

unread,
Jul 16, 2015, 2:29:25 PM7/16/15
to django...@googlegroups.com
try:

python manage.py [::]:8001

django will accept any requests on that port (localhost:8001, 127.0.0.1:8001, 192.168.0.102:8001)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

anotherdjangonewby

unread,
Jul 16, 2015, 5:23:16 PM7/16/15
to django...@googlegroups.com

When switching to debug=False I had also problems connecting my debug-server. For me I had to specify the server IP-address in the settings:


ALLOWED_HOSTS = ['localhost', '127.0.0.1', '192.168.1.21']


Maybe this helps.


Kai

Ted Thomas

unread,
Jul 16, 2015, 8:04:16 PM7/16/15
to django...@googlegroups.com
Jonathan, anotherdjangonewby,

Thanks.  I tried both suggestions, but there in no change in behavior.  No matter what I do,
the development server only takes requests at 127.0.0.1:8000.

I am including my settings.py file below ( with altered secret_key):

================


"""
Django settings for app3 project.

For more information on this file, see

For the full list of settings and their values, see
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

#wfk debug
print("WFK: BASE_DIR= " + BASE_DIR)

# Quick-start development settings - unsuitable for production

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'zzzz'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

#TEMPLATE_DEBUG = True  #wfk.  This is deprecated with Django 1.8

#ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['192.168.0.102']

# Application definition
INSTALLED_APPS = (
    'django_pdb',     #wfk for django-pdb debugger
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'report_builder',
    'app3',   #wfk. Application #3
    'bootstrap3',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django_pdb.middleware.PdbMiddleware', #wfk for django-pdb debugger
)

ROOT_URLCONF = 'app3.urls'  #WFK app3 is in BASEPATH
#ROOT_URLCONF = 'urls'
print("WFK: ROOT_URLCONF= " + ROOT_URLCONF) #DEBUG

WSGI_APPLICATION = 'app3.wsgi.application'

#Wfk: This stanza removed when upgrading to Django 1.8.  See "TEMPLATES =" below.
#TEMPLATE_CONTEXT_PROCESSORS = ( # wfk added this for img processing
#"django.contrib.auth.context_processors.auth",
#"django.core.context_processors.debug",
#"django.core.context_processors.i18n",
#"django.core.context_processors.media",
#"django.core.context_processors.static",
#"django.contrib.messages.context_processors.messages"
#)

TEMPLATES = [     # wfk added this when upgrading from Django 1.7.1 to 1.8.2
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            # insert your TEMPLATE_DIRS here
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
                # list if you haven't customized them:
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.contrib.messages.context_processors.messages',
            ],
            'debug':True,    #wfk: Do TEMPLATE debugging.  Replaces TEMPLATE_DEBUG. See 1.8 upgrade stuff
        },
    },
]

# Database

DATABASES = {

   # For postgres:
    # USER, PASSWORD, HOST are needed
    # Inside postgres, "CREATE DATABASE database_name"

     'default': {
         'ENGINE': 'django.db.backends.postgresql_psycopg2',
         #'NAME': 'app_1_db',  # Change to app3 later !!!
         'NAME': 'app3_db',  
         'USER': 'bill',
         'PASSWORD': 'bill',
         'HOST': '127.0.0.1',
         'PORT': '5432',
#        'ATOMIC_REQUESTS': True,  # Safe! See "Two Scoops" p 72
     }

}

# Internationalization

LANGUAGE_CODE = 'en-us'

#TIME_ZONE = 'UTC'
TIME_ZONE = 'America/Los_Angeles'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)

STATIC_URL = '/static/'  # refers to /home/bill/web_server/django/proj3/app3/static
STATIC_PATH = os.path.join(BASE_DIR,'app3/static/') #wfk 16-dec-2014
#wfk debug
print("WFK: STATIC_PATH= " + STATIC_PATH)
STATICFILES_DIRS = (STATIC_PATH,)

# WFK: temporary Directory for collectstatic operation
# WFK: "pythone manage.py collectstatic" will load the following file.
STATIC_ROOT = '/home/bill/junkd/app3_static'
# scp this up to stp and place it in "/static/" 
#   i.e. in /home/bill/web_server/django/proj3/app3/static

#MEDIA_ROOT = "/home/bill/django/wfkprojs/proj1/app3/media_root/"

MEDIA_ROOT =  os.path.join(BASE_DIR, 'app3/media_root/')
MEDIA_URL = '/media_root/'  #

#wfk debug
print("WFK: MEDIA_ROOT= " + MEDIA_ROOT)
print("WFK: MEDIA_URL= "  + MEDIA_URL)

# wfk additions follow. See "Settings" in Django Documentation

# Expire.  Aso use request.session.set_expiry(0) in view.
SESSION_EXPIRE_AT_BROWSER_CLOSE = True

#LOGIN_REDIRECT_URL = '/app3/wfk_protected/'  # '/accounts/profile/'
#LOGIN_URL          = '/app3/wfk_protected/'  #'/accounts/login/'
#LOGOUT             = '/accounts/logout/'

# django-report-builder stuff follows
REPORT_BUILDER_INCLUDE = ['Location', 'Observation', 'Measurement']
#REPORT_BUILDER_INCLUDE = []
   
#REPORT_BUILDER_EXCLUDE = ['user']#
REPORT_BUILDER_EXCLUDE = []

#REPORT_BUILDER_ASYNC_REPORT = True
REPORT_BUILDER_ASYNC_REPOR = False # If true, requure Celery

REPORT_BUILDER_GLOBAL_EXPORT = True
#REPORT_BUILDER_EMAIL_NOTIFICATION = False

Reply all
Reply to author
Forward
0 new messages