Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8433285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:20:43+00:00 2026-06-10T06:20:43+00:00

I’m currently using two Django applications (say A & B ) hosted on the

  • 0

I’m currently using two Django applications (say A & B) hosted on the same domain (but being served on different ports) through Apache. I believe my setup is correct, but I’m randomly getting 500s on both the sites. The 500 on A (say for example) occurs mostly after a request has been served on B (and vice versa).

Upon inspecting the error log (of say A for instance), I see that A‘s wsgi module is trying to access B‘s settings.py file (which obviously doesn’t happen to be there, since the project paths are different) [and this does happen the other way too, B’s wsgi raises an exception complaining of missing A’s settings.py file]. I’m not sure why they’d look for the other settings file, the imports (for settings.py) on all views are specific to the respective projects.

Here’s my setup:

A is being served on port 8080, B is being served on port 80.

VirtualHost:

<VirtualHost *:8080>

  ServerAdmin x@x.net
  ServerName  string1

  Alias /static/ /home/PATH_TO_PROJECT_A/static/

  <Directory /home/PATH_TO_PROJECT_A/static>
  Order deny,allow
  Allow from all
  </Directory>

  WSGIScriptAlias / /home/PATH_TO_PROJECT_A/wsgi.py

  <Directory /home/PATH_TO_PROJECT_A>
  <Files wsgi.py>
  Order deny,allow
  Allow from all
  </Files>
  </Directory>


  LogLevel warn
  ErrorLog  /SOME_PATH/errorA.log
  CustomLog /SOME_PATH/accessA.log combined
</VirtualHost>


<VirtualHost *:80>
  ServerName string1
  ServerAdmin x@x.net

  Alias /APP_B/static/ /home/PATH_TO_PROJECT_B/static/

  <Directory /home/PATH_TO_PROJECT_B/static>
  Order deny,allow
  Allow from all
  </Directory>

  WSGIScriptAlias /APP_B /home/PATH_TO_PROJECT_B/wsgi.py/

  <Directory /home/PATH_TO_PROJECT_B>
  <Files wsgi.py>
  Order deny,allow
  Allow from all
  </Files>
  </Directory>

  ErrorLog /home/SOME_PATH/error2.log
  CustomLog /home/SOME_PATH/access2.log combined

  # All other files on B:80 (other than /APP_B are served normally
  DocumentRoot /home/foo/public_html/xyz/public

</VirtualHost>

ports.conf:

NameVirtualHost *:8080
Listen 8080
Listen 80

<IfModule mod_ssl.c>
 Listen 443
</IfModule>

<IfModule mod_gnutls.c>
 Listen 443
</IfModule>

wsgi.py on ‘A’:

import os, sys

sys.path.append('home/PATH_TO_PROJECT_A') #1

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "PROJECT_A.settings") #2

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

And exactly the same on B, with changes to line #1 and #2.

Error I get from the error.log say for instance from A:

 [Sun Aug 26 17:01:49 2012] [error] [client x] Traceback (most recent call last):
 [Sun Aug 26 17:01:49 2012] [error] [client x]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 219, in __call__
 [Sun Aug 26 17:01:49 2012] [error] [client x]     self.load_middleware()
 [Sun Aug 26 17:01:49 2012] [error] [client x]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
 [Sun Aug 26 17:01:49 2012] [error] [client x]     for middleware_path in settings.MIDDLEWARE_CLASSES:
 [Sun Aug 26 17:01:49 2012] [error] [client x]   File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 184, in inner
 [Sun Aug 26 17:01:49 2012] [error] [client x]     self._setup()
 [Sun Aug 26 17:01:49 2012] [error] [client x]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
 [Sun Aug 26 17:01:49 2012] [error] [client x]     self._wrapped = Settings(settings_module)
 [Sun Aug 26 17:01:49 2012] [error] [client x]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 95, in __init__
 [Sun Aug 26 17:01:49 2012] [error] [client x]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
 [Sun Aug 26 17:01:49 2012] [error] [client x] ImportError: Could not import settings 'PROJECT_B.settings' (Is it on sys.path?): No module named PROJECT_B.settings

As you see A‘s error log complains that B‘s settings.py is missing. Please shed some light, I’ve no idea what’s wrong. I don’t see why one app would look for the other’s settings.py file to import?

Both the applications work and execute as expected, but they do break at random requests serving the 500 (which gets cleared if I refresh again).

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:20:45+00:00Added an answer on June 10, 2026 at 6:20 am

    Django breaks the geneated wsgi.py for running multiple Django instances in same process in different sub interpreters. Either use mod_wsgi daemon mode and delegate each to a separate daemon process group, is better anyway, or change:

    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "PROJECT_A.settings")
    

    to:

    os.environ["DJANGO_SETTINGS_MODULE"] = "PROJECT_A.settings"
    

    Similarly for other wsgi.py file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.