Menu
  • HOME
  • TAGS

Error in UWSGI(with nginx)

ubuntu,nginx,uwsgi

In /etc/uwsgi/apps-available/tiles.ini add: uid = root gid = www-data ...

python virtualenv(wrapper) + uwsgi + nginx (YET AGAIN)

python,virtualenv,uwsgi,virtualenvwrapper

In the first case you seem to be launching some kind of global (maybe one installed with sudo pip) uwsgi, as indicated by output: detected binary path: /usr/local/bin/uwsgi It may be missing python3 plugin to properly switch environments, and in general I found it is always simpler to use uwsgi...

Signal ALL workers in uWSGI configuration

python,server,wsgi,uwsgi

The third argument when you register a signal is the 'target': http://uwsgi.readthedocs.org/en/latest/Signals.html#signals-targets...

Running Out of Threads: UWSGI + Multithreaded Python Application with GeventHTTPClient

python,multithreading,uwsgi,gevent

Mixing non-blocking programming (geventhttpclient) with blocking one (a uWSGI thread/process) is completely wrong. This is a general rule: even if your app is 99% non blocking it is still blocking. This is amplified by the fact that gevent makes use of stack switching to simulate blocking programming paradigms. This is...

No module named flask while running uWSGI

python,import,flask,uwsgi

In the end what worked for me was adding -H /path/to/virtualenv to the uWSGI command: uwsgi --http-socket :3031 --plugin python --wsgi-file myflaskapp.py --callable app -H /path/to/virtualenv I also had different Python versions in the virtualenv and for uWSGI. I'm still investigating if this could cause any problems....

nginx + python app — how to enable error logging/stack trace

debugging,python-3.x,nginx,flask,uwsgi

Nginx will capture your app's console output, but you must make the app recover from exceptions. Else, you'll only get 500 or 400 errors from Nginx. Try running the app off Nginx until it seems stable. Use the logging module to capture app status information to your own log file....

unable to load configuration from app:app

flask,uwsgi

try this command = uwsgi -s /tmp/tmuwsgi.sock -w app:app --chmod-socket=666 --touch-reload /srv/www/tmapi/deployment.log ...

How to start uwsgi with flask and nginx

nginx,flask,uwsgi

This is probably related to how you installed uwsgi. This warning: !!! no internal routing support, rebuild with pcre support !!! has nothing to do with your application, it is about your uwsgi binary. Basically it says that one part of uwsgi has not been enabled in the binary that...

Cannot use manage.py because of uwsgi import in settings.py

python,django,uwsgi,manage.py

You should be able to catch the ImportError exception and pass. try: uwsgi except ImportError: pass Alternatively, you could use a different settings file for your production server. This would import the settings from your regular settings.py file, and include the import and code for autoreload....

How Django framework works behind the scenes?

python,django,uwsgi,gunicorn,django-middleware

You don't say where your "understanding" comes from, but it's not really accurate. Django itself is pretty agnostic about how it runs - it depends on the server - but it's very unusual for it to be invoked from scratch on each request. About the only method where that's the...

Nginx map client certificate to REMOTE_USER for uWSGI with fallback to basic auth?

ssl,nginx,mercurial,cgi,uwsgi

I see two possible solutions, you can either overwrite the uwsgi_param or use $remote_user a default value for the variable $ssl_client_s_dn_cn. To overwrite the uwsgi_param (this should also work with fastcgi_param), use the map directive as you suggested (just remove the ";" after "}"), and use the if_not_empty parameter for...

Concurrrency issue with psycopg2.ThreadConnectionPool, uWSGI and Flask

python,concurrency,flask,uwsgi,psycopg2

You are initializing the threadpool in the master, after it calls fork() (to generate workers) all will be messed up (unless you manage it). Ensure to initialize the pool one time per worker or use lazy-apps = true in uWSGI to load the app one time per worker.

uwsgi: Can't stop a Flask app

python,multithreading,flask,uwsgi

The problem is that Python threads don't die when the main thread exits, unless they are daemon threads. The solution is to daemonize any background thread: t = Thread(target=print_queue_size, args=()) t.setDaemon(True) # Does the trick t.start() ...

X-Forwarded-Proto and Flask

python,nginx,flask,uwsgi,werkzeug

You are missing the ProxyFix() middleware component. See the Flask Proxy Setups documentation. There is no need to subclass anything; simply add this middleware component to your WSGI stack: from werkzeug.contrib.fixers import ProxyFix from flask import Flask app = Flask(__name__) app.wsgi_app = ProxyFix(app.wsgi_app) If you have Flask installed, you have...

nginx and uWSGI gives “504 Gateway timeout”

django,nginx,uwsgi

I think you are running uwsgi in http mode --http 0.0.0.0:8002 but you have configured nginx as wsgi proxy change your uwsgi script as: uwsgi --socket :8002 --module wsgi --harakiri 5 Note that if you are running nginx and uwsgi on the same machine is better to use unix sockets...

uwsgi socket file not created

django,nginx,uwsgi

Changing owner to www-data on /var/www/django/ made it work.

Application served by uWSGI with Supervisord from Docker

django,docker,uwsgi,supervisord

How are you starting the docker container? I don't see any CMD or ENTRYPOINT script, so I'm unclear as to how anything is getting started. In general, I would advice avoiding things like supervisord unless absolutely necessary, just start uWSGI in the foreground from a CMD line. Try adding the...

Running rbtimer from emperor

python,django,flask,wsgi,uwsgi

You need a process (a worker or a mule) to run the signal handler. Spawn a worker (adding a socket directive) or a mule (adding mule = true). In the case of a mule you need to add target=mule to the @rbtimer decorator)

uWSGI env and PYTHON_EGG_CACHE configuration options

python,uwsgi

evn option exports an environment variables to the UWSGI web server process. The option can be specified manyt times to export multiple varibles. The values can be read from os.environ dict in Python. PYTHON_EGG_CACHE is not uWSGI specific and it is answered here: What is the Python egg cache (PYTHON_EGG_CACHE)?...

Why is uWSGI incapable of locating the functools module for Flask?

python,nginx,flask,debian,uwsgi

I re-imaged the system to Arch Linux to remove as many variables as possible, downloaded and built uWSGI from source, got around to installing a specific Python version and realized Python 3.2 isn't supported by Flask. When I installed it on Debian, it installed with Python 3.2 and Arch's package...

How to automatic control uwsgi log size

python,django,uwsgi

you need log-maxsize [uwsgi] ;... ;... log-maxsize = 2048 ...

Flask: Background thread sees a non-empty queue as empty

python,multithreading,flask,uwsgi

From the Things to Know documenation page: uWSGI tries to (ab)use the Copy On Write semantics of the fork() call whenever possible. By default it will fork after having loaded your applications to share as much of their memory as possible. If this behavior is undesirable for some reason, use...

Invalid transaction persisting across requests

python,flask,sqlalchemy,uwsgi,flask-sqlalchemy

Edit 2015-04-13: Mystery solved! TL;DR: Be absolutely sure your teardown functions succeed, by using the teardown-wrapping recipe in the 2014-12-11 edit! Started a new job also using Flask, and this issue popped up again, before I'd put in place the teardown-wrapping recipe. So I revisited this issue and finally figured...

Deployment of Python API

django,api,nginx,deployment,uwsgi

Security, what this is ultimately about, is and always has been a very complicated matter. The open internet is one of the most dangerous places. No matter how small and insignificant your server seems to be, people will find it and try to break it. If a web server is...

uwsgi + nginx + flask: upstream prematurely closed

python,nginx,flask,uwsgi

Change nginx.conf to include sendfile on; client_max_body_size 20M; keepalive_timeout 0; See self answer uwsgi upstart on amazon linux for full example...

How can I avoid uwsgi_modifier1 30 and keep WSGI my application location-independent?

nginx,uwsgi,cherrypy

My answer is really about simplifying things, because the following and the amount of configuration you have indicates one thing -- overkill. CherryPy ⇐ WSGI ⇒ uWSGI ⇐ uwsgi ⇒ Nginx ⇐ HTTP ⇒ Client CherryPy has production ready server that natively speaks HTTP. No intermediary protocol, namely WSGI, is...

uWSGI unique timer python decorator

uwsgi,python-decorators

Use the uWSGI locking api: from uwsgidecorators import * @timer(600) #every 10 minutes def myfunction(signum): if uwsgi.is_locked(): return uwsgi.lock() .... uwsgi.unlock() http://uwsgi-docs.readthedocs.org/en/latest/Locks.html...

Populate cache before app is fully available

uwsgi

A prerequisite is that uWSGI actually has caching enabled, something like: [uwsgi] cache2 = name=mycache,items=100 There are many options for startup hooks. Take a look at this page in the uWSGI doc. You can choose at what point in the uWSGI startup sequence you want to hook up (as-root, as-user,...

Uwsgi running in foreground though it shouldn't

uwsgi

You should also pass --daemonize <logfile> to the emperor. And see How to make uwsgi --emperor run as daemon...

Uwsgi: “Cannot assign requested address”

python,django,uwsgi,ports

Solution Found: Make sure your interfaces are correct by running ifconfig lo up ...

uwsgi --stats show different port number for socket

uwsgi

When you start uWSGI with --http you are starting a http proxy that forward requests to the real instance. The stats you get are from the real instance, that is bound to a random port (the one you see in stats) where the http router/proxy forward requests. You can have...

How to create one uwsgi log file per day?

logging,uwsgi,log-rotation

uWSGI by itself can only "split by size", with the --log-maxsize option. Time-based approaches are using classic logrotate or apache rotatelogs (http://httpd.apache.org/docs/2.2/programs/rotatelogs.html) that you can combine with uWSGI logpipe plugin. Finally you can have an nginx like behaviour triggering a reload at midnight of the uWSGI instance (you can even...

Fixing broken pipe error in uWSGI with Python

python,rest,timeout,wsgi,uwsgi

it depends on your frontend server. For example nginx has the uwsgi_read_timeout parameter. (generally set to 60 seconds). The uWSGI http router as the --http-timeout default to 60 seconds and so on. As you are talking about a rest api i am quite doubtful it requires more than 60 seconds...

i can access flask app directly the port 8080 though then through nginx reverse proxy I get an error

nginx,flask,uwsgi

seems to be working now after changing to the uwsgi ini config format instead of the cmd line uwsgi.ini [uwsgi] socket = :8080 chdir = /home/ec2-user/prod_demo master = True venv = /home/ec2-user/venv callable = app wsgi-file = /home/ec2-user/prod_demo/manage.py enable-threads = True calling uwsgi.ini in shell / upstart (hopefully) /home/ec2-user/venv/bin/uwsgi --ini...

Unable to link Flask module to nginx through uwsgi

python,nginx,flask,uwsgi

You're application function does not call your flask app, which is why every route returns "Hello World", 200. I'm pretty sure you have two easy options. The first is to drop the application function and replace it with application = app. The second would be to change the uwsgi line...

wsgi nginx error: permission denied while connecting to upstream

sockets,ubuntu,nginx,wsgi,uwsgi

miguel5, I also followed that tutorial and ran into the same issue. After quite a bit of trial and error, the following steps allowed me to run uWSGI and nginx successfully: My nginx.config file: server { listen 80; server_name localhost; location / { try_files @yourapplication; } location @yourapplication; { include...

uWSGI + Docker: pyuwsgi: executable file not found in $PATH

python,django,docker,uwsgi

Turns out I'm pretty dumb. [docker] section of uwsgi.ini needs to have ini = :base, not init = :base. The base section wasn't being parsed, so the wsgi module was never getting set. Always proofread your work, friends....

Is it necessary to run miltiple uWSGI web-sites with different users?

linux,deployment,nginx,web-deployment,uwsgi

It is a general security rule. Immagine one of your app being compromised, if it runs with the same permissions of the others it will be potentially able to damage them as well.

Django Internal Server Error instead of 404

python,django,nginx,uwsgi

It seems you have a custom processor trying to resolve path: File "./project/context_processors.py", line 88, in app_delegate app_name = resolve(request.path).app_name Quoting django resolve() docs: If the URL does not resolve, the function raises a Resolver404 exception (a subclass of Http404) . I suggest to you to manage exception in custom...

Nginx/Uwsgi log showing duplicate requests

python,flask,uwsgi

Sorry false alarm. This was my Devops incorrectly pinging my actual application route for heartbeat. Sorry for the confusion.

uwsgi - remove “address space usage” message from the log file

python,uwsgi

You told uWSGI to log any response with zero size (--log-zero). Instead if you mean removing the memory report just drop the -m flag (it is a shortcut for --memory-report)

Django model class is None in manager

python,django,django-models,uwsgi

Use self.model to access the model from the manager: for possible_suit in self.model.SUITS: ... ...

How to convert http to https using nginx for local server(self signed cetificate)

python,django,ssl,nginx,uwsgi

You are getting the message because you are using a self signed certificate, you need to use a SSL certificate from a trusted provider to avoid the warning. You can get a free SSL cert that is trusted by most major browsers at StartSSL. You can see all of the...

flask + nginx + uwsgi_response_sendfile_do() TIMEOUT

python,nginx,flask,download,uwsgi

You should set the uwsgi_max_temp_file_size setting according to the documentation: When buffering of responses from the uwsgi server is enabled, and the whole response does not fit into the buffers set by the uwsgi_buffer_size and uwsgi_buffers directives, a part of the response can be saved to a temporary file. This...

How to show custom error page on uWSGI

cgi,uwsgi

use the internal routing subsystem: error-route-status = 404 static:yourfile.html or error-route-status = 404 cgi:yourscript.foo http://uwsgi-docs.readthedocs.org/en/latest/InternalRouting.html...

uwsgi upstart on amazon linux

nginx,amazon-ec2,flask,uwsgi,upstart

To fix this I did a few things. - Moved all scripts from the home directory to an /var/www/ - created an www group and www user and chown /var/www to www:www Full Instructions Create a user and group www and www sudo groupadd www sudo adduser www -g www...

How integrate a websocket between tornado and uwsgi?

python,websocket,tornado,uwsgi

The uWSGI tornado loop engine is no more than a proof of concept, you could try to use it but native uWSGI websockets support or having nginx routing requests to both uWSGI and tornado are better (and more solid) choices for sure.

uWSGI process doesn't inherit permissions associated with group its uid belongs to

django,nginx,uwsgi

Following up on dgel's suggestion to learn about Unix permissioning: when you run processes in Unix, there are basically 3 ways you can wind up being "green lit" permissions-wise by the OS. The user calling the command can be user-permissioned for the disk operation (green-lit because of effective user id)...

How to reload a python library in a flask, nginx, uwsgi stack?

python,nginx,flask,uwsgi

The Python process started by uWSGI only interprets the source once at startup, any code changes after that will not affect the in-memory process. You should probably just manually restart the uWSGI process when this happens. Alternatively you can tell uWSGI to auto-reload if files or directories change: http://uwsgi-docs.readthedocs.org/en/latest/Options.html#touch-reload.

Deploying Flask application with uwsgi and nginx

python,deployment,nginx,flask,uwsgi

It doesn't matter how complex your application is. You tell uWSGI where the entry is, the rest is processed normally with Python imports. In your case the entry is module = %(app) and callable = app. So uWSGI will load the module and send requests to the callable which is...

sqlite3 cannot open database file, running Centos, flask uwsgi nginx

nginx,sqlite3,flask,centos,uwsgi

So it turns out that the file name prefix of sqlite/// is incorrect. I don't understand this, as it worked before. I just put the file name only and it works now.

Flask sub.domain.com overrides session on domain.com

session,nginx,flask,subdomain,uwsgi

By mistake I thought it has nothing to do with my reverse proxy or uwsgi. Actually it was problem with reverse proxy and I could solve my problem by adding following rules to nginx: proxy_cookie_domain media.$host $host; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect...

Have created a docker that installs nginx, python, uwsgi and django. How do I test it within a VM?

django,nginx,docker,uwsgi

In your docker file define the network ports you will expose for external access like so: EXPOSE 80 This will expos the port 80 of the container to docker. Now you can tell docker to NAT and Forward this port to an free port of your docker host to access...

Atomic log file rotation with Flask and RotatingFileHandler

python,logging,flask,multiprocessing,uwsgi

Note that writing to a single log file from multiple processes isn't supported, because there is no cross-platform synchronisation mechanism that can be used. See this cookbook entry for a suggested approach which might work for you.

Django, uwsgi and nginx - Internal Server Error

python,django,nginx,uwsgi

You are probably lacking a chdir line in your uwsgi_conf.ini. Or, probably, you have a chdir line, but it is wrong. This is confirmed by your traceback: File "./wsgi.py", line 16, in <module> Here you should see ./api/wsgi.py, not ./wsgi.py. Clearly, the working directory of uWSGI is the api/ directory,...

nginx permission denied while reading upstream - even when run as root

python,nginx,flask,uwsgi

Okay! So the problem was, I think, related to this bug. It seems that even though apparmor wasn't configured to prevent access to sockets inside the containers it was actually doing something to prevent reading from them (though not creation...) so turning off apparmor for the container (following these instructions)...

uwsgi cannot work on a cloud server

python,uwsgi

Check the firewall rules. Arbitrary ports like 8001 tend to be disabled from outside access out of the box. Should work just fine from the command line on the server, e.g. $ curl localhost:8001.

uWSGI - Production touch-reload git commit

django,git,service,production-environment,uwsgi

touch-reload = .git/index Ended up working fine...

uWSGI and Django segmentation fault

django,segmentation-fault,zip,uwsgi

The problem happens because your process fails to allocate a chunk of memory. When I first look at your code, the first thing that drew my attention was that you are loading entire content of file into memory and read them all at once at each iteration. zip.writestr("{0} - {1}.{2}".format(num,...

Starting uWSGI service fails silently

django,ubuntu,uwsgi,upstart

Thanks to nmgeeks comment, I started looking at other places where uWSGI is configured. While trying to move everything our own app related under /srv I deleted /run/uwsgi directory, where uWSGI is trying to create a PID file. You can find the reference at /usr/share/uwsgi/conf/default.ini. Too bad uWSGI doesn't produce...

nginx uwsgi websockets 502 Bad Gateway upstream prematurely closed connection while reading response header from upstream

django,nginx,websocket,redis,uwsgi

I found the issue. My [runserver] socket (app.sock) should be pointed under upstream django and my [wsserver] socket (django.sock) should be pointed under location /ws/ like so: upstream django { server unix:/opt/django/app.sock; } server { listen 80 default_server; charset utf-8; client_max_body_size 20M; sendfile on; keepalive_timeout 0; large_client_header_buffers 8 32k; location...

Testing my Django app with uWSGI

django,nginx,uwsgi,dev-to-production

I had several things badly configured primarily the socket permission and some other small thigs. That's why my Nginx was not able to talk to uWGSI. This really good uWSGI howto Django & NginX helped me a lot to make work....

Google Oauth2 redirects after 2.1 minutes on login

django,nginx,google-oauth,uwsgi

I had the same issue on a server 2 weeks ago. In my case, the server was resolving all URLs using ipv6. It would take 2 minutes to resolve each URL. So, I just turned off ipv6. Try disabling it. ...

Django Running on uWSGI with NGiNX - INI Method Not Working

django,nginx,uwsgi

I'm not which document I read that lead me down this faulty path, but I was using only the number for the INI socket configuration: # WRONG!!! socket = 8001 Should be, just llike the manual command line method: # CORRECT socket = :8001 Or like most docs describe: #...

uWSGI --http :80 doesn't listen IPv6 interface

http,python-3.x,ipv6,uwsgi

In your INI config file specify something like this [uwsgi] socket = [::]:your_port_number Or from the CL, ./uwsgi -s [::]:your_port_number The server shall now listen along all the interfaces (including IPv4, if the underlying OS supports dual stack TCP sockets) ...

Flask/uWSGI - too many processes after some time

python-3.x,flask,uwsgi

If anyone sees this issue with a similar setup, the problem was threads where disabled. uWSGI indicates this at startup (see question body): *** Python threads support is disabled. You can enable it with --enable-threads *** add command line parameter --enable-threads or add the following to the uWSGU .ini initialization...

NGINX with uwsgi and django connection refused

django,nginx,wsgi,uwsgi

SOLUTION: I managed to resolve problem. The reason was wrong linking the nginx.conf file. I accidently linked in to sites-available, not as I was supposed to sites-enabled Thanks...

Super basic uwsgi configuration

python,uwsgi

If you want to run uWSGI without a web server in front of it, use http option instead of socket. See Native HTTP support. Also, use 0.0.0.0:80 as an address if you are accessing from a remote machine....

uwsgi broken pipe - django, nginx

python,django,nginx,tastypie,uwsgi

you can safely ignore them, they are triggered by the client (or nginx) disconnecting in the middle of the request. As the response times are really low, it is very probably a client disconnection. Btw, post your nginx and uWSGI configuration for being sure.

ImportError: No module when running uwsgi

python,uwsgi

You need to add an __init__.py in the model folder if you want to use it as a python package. It was probably working for in debug mode because the parent directory was in your PYTHONPATH.

Does UWSGI influence LDAPS Requests from an underlying Django app?

python,django,active-directory,uwsgi,python-ldap

By playing around with the options on commandline ldapsearch a colleague and me found out what resolves the problem - but not what exactly caused the problem in the first place. By explicitly setting the HOST option, we got it to work. In python it looks like this: l.set_option(ldap.OPT_HOST_NAME, settings.AD_DNS_NAME)...

Django App Improperly Configured - The app module has multiple filesystem locations

django,uwsgi

The problem was that I deleted a __init__.py file. Apparently, django uses them to know which folders are packages, so they are kind of important.