Django Ngnix Uwsgi :Could not connect to the requested server host - python

I tried to follow the tutorial for deploying django app on ec2 using this tutorial, however getting an error:
"Could not connect to the requested server host"
When trying to deploy the first site with ref to tutorial. Only thing I changed is the server_name firstsite.com to public IP of the machine. Please help me figure, where I can find out

My guess is your EC2 instance has firewall rules (security groups) which prevent you from connecting to your app. You can follow these directions to enable inbound traffic to your instance.

Fixed my error,firstly it was a cache of ec2 on my browser,
Secondly,my config ngnix was a symbolic link to the ngnix was not updated.
I initially uninstalled nginx and then tried to replicate the scenario,then
i updated my symbolic links which got my site running up

Related

Unable to access Flask app hosted on EC2 after adding https support

I have a Flask application currently using http being hosted on an ec2 instance. I want to host my application using https. Currently with http, I am able to access my application (running on 0.0.0.0 port 80) by just accessing the ec2 public IP address (displays Running on http://0.0.0.0:80/, and I am able to use my app at http://IP).
I am following this tutorial to test https support: https://blog.miguelgrinberg.com/post/running-your-flask-application-over-https.
When I add the most basic app.run(ssl_context='adhoc') to my program, the app is now Running on https://0.0.0.0:80/, but I am unable to access my app at https://IP. I opened up my port 403 in my EC2 settings however I am still unable to communicate with my app using https...no response whenever I make a request.
The same no response occurs when I run the application with gunicorn. Am I missing something? I think my requests are well formed, however I am never able to communicate with my app when using https.
Simple way is put your instance behind ALB. ALB is not only load balancer, but also integrate ACM for free.

Connect GAE Remote API to dev_appserver.py

I want to execute a Python script that connects to my local dev_appserver.py instance to run some DataStore queries.
The dev_appserver.py is running with:
builtins:
- remote_api: on
As per https://cloud.google.com/appengine/docs/python/tools/remoteapi I have:
remote_api_stub.ConfigureRemoteApiForOAuth(
hostname,
'/_ah/remote_api'
)
In the Python script, but what should the hostname be set to?
For example, when dev_appserver.py started, it prints:
INFO 2016-10-18 12:02:16,850 api_server.py:205] Starting API server at: http://localhost:56700
But I set the value to localhost:56700, I get the following error:
httplib2.SSLHandshakeError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)
(Same error for any port that has anything running on it - e.g. 8000, 8080, etc).
If anyone has managed to get this to run successfully, what hostname did you use?
Many thanks,
Ned
The dev_appserver.py doesn't support SSL (I can't find the doc reference anymore), so it can't answer https:// requests.
You could try using http-only URLs (not sure if possible with the remote API - I didn't use it yet, may need to disable handler secure option in app.yaml config files).
At least on my devserver I am able to direct my browser to the http-only API server URL reported by devserver.py at startup and I see {app_id: dev~my_app_name, rtok: '0'}.
Or you could setup a proxy server, see GAE dev_appserver.py over HTTPS.

How can I access I web app that I am running locally in AWS from my computer?

I got AWS today and have managed to get a web app up and running there, as you can see here:
I have managed to do that by following this guide:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-flask.html#python-flask-run-locally
But I have not succeeded in accessing that web app from my browser. In the browser on my physical computer I try to visit the address http://127.0.0.1:5000/ and I get ERR_CONNECTION_REFUSED:
What is the likely reason for this?
How can I resolve it?
Your problem is that your website is running on the "EC2" instance and 127.0.0.1 is relative the EC2 instance not your laptop.
SO in order to access your website you need to get public ip address of the host. Then enter it instead of 127.0.0.1 and assuming you opend up security group then you should see the result.

Web2py unable to access internet [connection refused]

I have deployed a web2py application on a server that is running on Apache web server.
All seems to be working fine, except for the fact that the web2py modules are not able to connect to an external website.
in web2py admin page, i get the following errors :
1. Unable to check for upgrades
2. Unable to download because:
I am using web2py 1.9.9, CentOS 5
I am also behind an institute proxy. I am guessing that the issue has to do something with the proxy configurations.
Try testing the proxy theory by ssh -D tunneling to a server outside the proxy and seeing if that works for you.

Cannot access django app through ip address while accessing it through localhost

I have a django app on my local computer. I can access the application from a browser by using the url: http://localhost:8000/myapp/
But I cannot access the application by using the ip of the host computer: http://193.140.209.49:8000/myapp/ I get a 404 error.
What should I do? Any suggestions?
I assume you're using the development server. If so, then you need to specifically bind to your external IP for the server to be available there. Try this command:
./manage.py runserver 193.140.209.49:8000

Categories