browser error Refused to connect to web application while the ports are open

Hi expertsAWS opened ports for reference,

   My web application is running on aws ubuntu 16.  I have the following ports open from aws.  
It has the following applications running on ubuntu

uwsgi with nginx -  i  Think it uses port 80
node.js with react - react is rendering on port 9009
webpack with webpack.config.js - which creates js file which will be using port 80
npm run django: runserver 0.0.0.0:8000  uses port 8000
elastic search :9200 uses port 9200
postgresql used port:5432

Please see the opened ports on aws.  screenshot for reference.

With putty I connect to linux ubuntu machine with the following ip address 54.252.92.17

There is docker application which runs inside that linux box uses nginx, postgres, elasticsearch

When I run docker application, and I able to see from browser with http://54.252.92.17/

Where as when I run python manage.py runserver 0.0.0.0:8000 I am not able to see the application.

The site can't be reached 54.252.92.17 refused to connect error.

Whereas I can see the docker application when the docker is run.

Please help me why the python application is not running on the browser, where as Docker application runs well.

With python manage.py runserver 0,0,0,0:8000 I am running from the source code.  Whereas with docker I am running the docker image.

Both are same application.  

Please help me in fixing this issue.

with many thanks,
Bharath AK
LVL 1
Bharath A.KAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Phil PhillipsDevOps ArchitectCommented:
For the python app, have you tried connecting directly like http://54.252.92.17:8000 ? Seems like the command is set up to have it listen on port 8000.
Bharath A.KAuthor Commented:
Hi Phillips,

      I had tried http://54.252.92.17:8000

When I run python manage.py runserver 0.0.0.0:8000 I get the following error.

I got some other errors please see the errors below

Django version 1.11.1, using settings 'ntdl.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
Internal Server Error: /
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/dist-packages/django/utils/deprecation.py", line 138, in __call__
    response = self.process_request(request)
  File "/usr/local/lib/python3.6/dist-packages/django/middleware/security.py", line 25, in process_request
    host = self.redirect_host or request.get_host()
  File "/usr/local/lib/python3.6/dist-packages/django/http/request.py", line 105, in get_host
    if domain and validate_host(domain, allowed_hosts):
  File "/usr/local/lib/python3.6/dist-packages/django/http/request.py", line 579, in validate_host
    if pattern == '*' or is_same_domain(host, pattern):
  File "/usr/local/lib/python3.6/dist-packages/django/utils/http.py", line 291, in is_same_domain
    pattern = pattern.lower()
AttributeError: 'ellipsis' object has no attribute 'lower'
"GET / HTTP/1.1" 500 11970
Internal Server Error: /favicon.ico
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/dist-packages/django/utils/deprecation.py", line 138, in __call__
    response = self.process_request(request)
  File "/usr/local/lib/python3.6/dist-packages/django/middleware/security.py", line 25, in process_request
    host = self.redirect_host or request.get_host()
  File "/usr/local/lib/python3.6/dist-packages/django/http/request.py", line 105, in get_host
    if domain and validate_host(domain, allowed_hosts):
  File "/usr/local/lib/python3.6/dist-packages/django/http/request.py", line 579, in validate_host
    if pattern == '*' or is_same_domain(host, pattern):
  File "/usr/local/lib/python3.6/dist-packages/django/utils/http.py", line 291, in is_same_domain
    pattern = pattern.lower()
AttributeError: 'ellipsis' object has no attribute 'lower'
"GET /favicon.ico HTTP/1.1" 500 11967


Please help me how to fix this error.

With Many thanks,
Bharath AK
Bharath A.KAuthor Commented:
Hi Scott

      Thankyou,

With Kind Regards,
Bharath AK
Webinar: Cyber Crime Becomes Big Business

The rising threat of malware-as-a-service is not one to be overlooked. Malware-as-a-service is growing and easily purchased from a full-service cyber-criminal store in a “Virus Depot” fashion. Join us in our upcoming webinar as we discuss how to best defend against these attacks!

Phil PhillipsDevOps ArchitectCommented:
I'm not a Python/Django expert, but this is where it's failing:
AttributeError: 'ellipsis' object has no attribute 'lower'

Open in new window


It *might* be a rogue ellipsis (...) somewhere in one of your configuration files, possibly where allowed_hosts is being set.
Bharath A.KAuthor Commented:
Hi Phill,

       I had checked the config inside /usr/bin/python-config and also inside my bin/python-config, and searched for ... in that file
but ... text is not all available in python-config file.  Do I have check for any other file?

With Many Thanks,
Bharath AK
Phil PhillipsDevOps ArchitectCommented:
Is there perhaps a settings.py or similar within the directory that holds the webapp?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bharath A.KAuthor Commented:
Hi Phill

I had checked the following files manually opening and checking it

root@ip-10-252-14-11:/home/ubuntu/workarea/sourcecode/ntdl# python3 manage.py runserver 0.0.0.0:80
Performing system checks...

System check identified no issues (0 silenced).
March 21, 2018 - 17:59:58
Django version 1.11.1, using settings 'ntdl.settings'
Starting development server at http://0.0.0.0:80/
Quit the server with CONTROL-C.
Internal Server Error: /
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/dist-packages/django/utils/deprecation.py", line 138, in __call__
    response = self.process_request(request)
  File "/usr/local/lib/python3.6/dist-packages/django/middleware/security.py", line 25, in process_request
    host = self.redirect_host or request.get_host()
  File "/usr/local/lib/python3.6/dist-packages/django/http/request.py", line 105, in get_host
    if domain and validate_host(domain, allowed_hosts):
  File "/usr/local/lib/python3.6/dist-packages/django/http/request.py", line 579, in validate_host
    if pattern == '*' or is_same_domain(host, pattern):
  File "/usr/local/lib/python3.6/dist-packages/django/utils/http.py", line 291, in is_same_domain
    pattern = pattern.lower()
AttributeError: 'ellipsis' object has no attribute 'lower'
"GET / HTTP/1.1" 500 12110
Internal Server Error: /favicon.ico
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/dist-packages/django/utils/deprecation.py", line 138, in __call__
    response = self.process_request(request)
  File "/usr/local/lib/python3.6/dist-packages/django/middleware/security.py", line 25, in process_request
    host = self.redirect_host or request.get_host()
  File "/usr/local/lib/python3.6/dist-packages/django/http/request.py", line 105, in get_host
    if domain and validate_host(domain, allowed_hosts):
  File "/usr/local/lib/python3.6/dist-packages/django/http/request.py", line 579, in validate_host
    if pattern == '*' or is_same_domain(host, pattern):
  File "/usr/local/lib/python3.6/dist-packages/django/utils/http.py", line 291, in is_same_domain
    pattern = pattern.lower()
AttributeError: 'ellipsis' object has no attribute 'lower'
"GET /favicon.ico HTTP/1.1" 500 12107

Then I went inside the file /usr/local/lib/python3.6/dist-packages/django/utils/http.py line 291 in is_same_domain

please see the implementation of is_same_domain  I am not able find where the error is

def is_same_domain(host, pattern):
    """
    Return ``True`` if the host is either an exact match or a match
    to the wildcard pattern.

    Any pattern beginning with a period matches a domain and all of its
    subdomains. (e.g. ``.example.com`` matches ``example.com`` and
    ``foo.example.com``). Anything else is an exact string match.
    """
    if not pattern:
        return False

    pattern = pattern.lower()
    return (
        pattern[0] == '.' and (host.endswith(pattern) or host == pattern[1:]) or
        pattern == host
    )


I am not able to find where the error is   Please help in resolving this

With Many Thanks,
Bharath AK
Bharath A.KAuthor Commented:
Hi Phill

I had checked the settings.py in the project directory it doesnot have ... text inside it.

With Many Thanks,

Bharath AK
Bharath A.KAuthor Commented:
Hi Phill,

      I am able to resolve this issue.  I add print inside is_same_domain(host, pattern): before pattern.lower()  then ran the applications.
I got three logs test_site, test_site2, eclipses.   I had searched for test_site in my project folder

I got ALLOWED_HOSTS = ['test_site', 'test_site2', ...] in settings.py.  I had missed the search in vim editor I had searched for /... in vi editor in settings.py but missed some how.  Then what I did is removed ... and it started working.

Thank you so much.

With Many Thanks,

Bharath AK
Bharath A.KAuthor Commented:
Thanks Phill
Phil PhillipsDevOps ArchitectCommented:
Nice - glad you were able to find it!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AWS

From novice to tech pro — start learning today.