Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
NGINX server running FLASK on Raspberry Pi

I am trying to run a flask application with NGINX server on Pi Model 3B+. The code in the directory /home/pi/api/api.py. I am following this article https://www.raspberrypi-spy.co.uk/2018/12/running-flask-under-nginx-raspberry-pi/

My WSGI ini file

[uwsgi]
chdir = /home/pi/api
module = api:app

master = true
processes = 1
threads = 2

uid = www-data
gid = www-data

socket = /tmp/api.sock
chmod-socket = 664
vacuum = true

My uwsgi proxy after removing defaults

sudo nano /etc/nginx/sites-available/api_proxy
server {
listen 80;
server_name localhost;

location / { try_files $uri @app; }
location @app {
include uwsgi_params;
uwsgi_pass unix:/tmp/api.sock;
}
}

My uwsgi.service file

[Unit]
Description=uWSGI Service
After=network.target

[Service]
User=www-data
Group=www-data
WorkingDirectory=/home/pi/flasktest/
ExecStart=/usr/local/bin/uwsgi --ini /home/pi/api/uwsgi.ini

[Install]
WantedBy=multi-user.target

But when I start the server using

sudo systemctl status uwsgi.service

I get this error

uwsgi.service - uWSGI Service
   Loaded: loaded (/etc/systemd/system/uwsgi.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-04-22 02:58:37 IST; 51min ago
 Main PID: 464 (uwsgi)
    Tasks: 3 (limit: 2319)
   Memory: 13.5M
   CGroup: /system.slice/uwsgi.service
           ├─464 /usr/local/bin/uwsgi --ini /home/pi/api/uwsgi.ini
           └─728 /usr/local/bin/uwsgi --ini /home/pi/api/uwsgi.ini

Apr 22 03:40:32 websync uwsgi[464]:   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
Apr 22 03:40:32 websync uwsgi[464]:   File "<frozen importlib._bootstrap_external>", line 724, in exec_module
Apr 22 03:40:32 websync uwsgi[464]:   File "<frozen importlib._bootstrap_external>", line 859, in get_code
Apr 22 03:40:32 websync uwsgi[464]:   File "<frozen importlib._bootstrap_external>", line 916, in get_data
Apr 22 03:40:32 websync uwsgi[464]: PermissionError: [Errno 13] Permission denied: './api.py'
Apr 22 03:40:32 websync uwsgi[464]: unable to load app 0 (mountpoint='') (callable not found or import error)
Apr 22 03:40:32 websync uwsgi[464]: *** no app loaded. going in full dynamic mode ***
Apr 22 03:40:32 websync uwsgi[464]: *** uWSGI is running in multiple interpreter mode ***
Apr 22 03:40:32 websync uwsgi[464]: gracefully (RE)spawned uWSGI master process (pid: 464)
Apr 22 03:40:32 websync uwsgi[464]: spawned uWSGI worker 1 (pid: 728, cores: 2)

Kindly help.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The error indicates that UWSGI does not have permission to access the file api.py. From your configuration, UWSGI is running with the user and group www-data. Check that that user or group has at least read permissions on that file.

As an aside, unless you need some of the capabilities of nginx (certificate handling, multiple concurrent connections, very fast response times for static files, or some other features), you could eliminate nginx and UWSGI and have that much less to worry about. If this is going to be a public-facing server, then yes, keep on your route. But if this is some private device with a simple web interface, eliminate complexity.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!