404 on Nginx running on docker (uwsgi)

I have been battling with this and can’t get my head around it.

I have a simple Dockerfile which works and I use supervisord as CMD to start nginx and uwsgi. And it does the job but I get back 404. So what I do is to instead start the docker with /bin/bash and manually start things and debug, e.g.:

  • Docker - COPY/ADD files remove the trailing line
  • Why is exposing known_hosts dangerous
  • Start Docker Containers In Specific Order After Reboot
  • Create image-stream on image from private registry on OpenShift
  • Unable to connect to dockerized postgres on localhost, but remote connection is working
  • Continuous deployment with docker
  • sudo docker run -t -i -p 8095:80  myimage /bin/bash

    So this is my nginx conf (in sites-available and then a link in sites-enabled):

    server {
        listen 80;
        location / {
            include uwsgi_params;
            uwsgi_pass unix:/WikiRockWord2Vec/WikiRockWord2Vec.sock;

    and this is my uwsgi ini:

    module = wsgi
    master = true
    processes = 5
    socket = /WikiRockWord2Vec/WikiRockWord2Vec.sock
    chmod-socket = 777
    vacuum = true
    uid = www-data
    die-on-term = true

    Socket does get created and I have changed permission to 777 to make sure all nginx has access to. But it seems nginx does not send to upstream anyway.

    Browsing to localhost:8095 brings the nginx homepage find but any other route returns 404. Nginx error log is empty.

    I have confirmed that nginx reads the .conf (by adding spelling mistake and see the error in the nginx log) but changing socket location has no impact as if it does not even care about that section. In similar cases on my ubuntu box when the sock file does not exist or there is a permission issue, I get 502 and some hint in the logs. But here I get nothing, as if UWSGI NOT CONFIGURED AGAINST NGINX.

    I am lost, can you please help? Am I missing module configuration in nginx (similar to apache)? I am new to nginx.

  • Pycharm not showing all files from django external library
  • Control lifetime of .NET Core console application hosted in docker
  • Dockerizing npm & bower install using the digitallyseamless/nodejs-bower-grunt docker image
  • Is running Docker on bare metal maintainable?
  • How to run a cron job inside a docker container?
  • Getting error installing nodejs when building from docker
  • 2 Solutions collect form web for “404 on Nginx running on docker (uwsgi)”

    404 is probably because your nginx conf file’s server block incorrect, i think is because your server_name part.

    so here is my modified version, you can check if it working

    server {
        listen 80 default_server;
        location / {
            uwsgi_pass unix:///WikiRockWord2Vec/WikiRockWord2Vec.sock;
            include uwsgi_params;

    Configuring Nginx, uWSGI, Supervisord, etc, (and just for a Flask application) could be difficult, so I made a public (and open source) Docker image with all the bells and whistles that you can use to build a Python Flask web application.

    It has uWSGI for running the application, Nginx to serve HTTP and Supervisord to control them, so you don’t have to learn how to install and configure all those to build your Python Flask web app.

    It seems like uWSGI with Nginx is one of the more robust (and with great performance) ways to deploy a Python web app. Here are the benchmarks: http://nichol.as/benchmark-of-python-web-servers.

    There are even some template projects you can use to bootstrap your own. And also, you don’t have to clone the full project or something, you can just use it as a base image.

    Docker Hub: https://hub.docker.com/r/tiangolo/uwsgi-nginx-flask/

    GitHub: https://github.com/tiangolo/uwsgi-nginx-flask-docker

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.