Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk10 min

How to Set Up uWSGI on an Ubuntu VPS

Deploy uWSGI safely on an Ubuntu VPS with a non-root user, virtual environment, systemd supervision, a protected Unix socket, and Nginx.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable Ubuntu VPS pattern is a non-root application user, an isolated Python environment, a Unix socket, a systemd-managed uWSGI process, and Nginx as the public-facing server. Install uWSGI in the application virtual environment, verify that the application imports there, make systemd create a protected /run/uwsgi/ directory, point Nginx at the identical socket path, and test locally before enabling public HTTPS and firewall rules.

What the finished deployment looks like

A request follows this path:

  1. The client connects to Nginx on the VPS.
  2. Nginx loads the standard uWSGI parameter definitions with include uwsgi_params;.
  3. Nginx forwards the request through a Unix socket such as /run/uwsgi/myapp.sock.
  4. uWSGI, supervised by systemd, sends the request to the application module inside its virtual environment.

This arrangement keeps the application process away from the public network, gives systemd responsibility for startup and recovery, and leaves Nginx to handle the externally visible HTTP endpoint. A loopback TCP listener is possible, but it should be a deliberate choice rather than the default.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Decide the deployment shape before changing files

One application or several

Situation Recommended control model What changes
One application on the VPS A dedicated systemd unit launching one uWSGI configuration There is one service, one socket, one virtual environment, and one set of ownership rules.
Several independent applications uWSGI Emperor with a vassals directory Each application gets its own configuration, uid/gid, socket, and working directory; the Emperor watches the directory.

Emperor mode is designed for the second case. Adding a vassal configuration starts an application, changing that file reloads the application, and removing it stops the application. Keep every vassal least-privileged instead of running all applications as one account.

Unix socket or TCP socket

Choice Best fit Important consideration
Unix socket Nginx and uWSGI on the same VPS It avoids a network listener and lets filesystem owner, group, and mode protect the endpoint. Both programs must use exactly the same path.
Loopback TCP A deliberate integration that needs a TCP endpoint Bind to loopback, not a public interface, unless you have a specific, reviewed reason to expose it. The official Nginx example uses uwsgi_pass localhost:9000;.

For a conventional single-VPS installation, choose the Unix socket. It is easier to keep private and makes accidental exposure less likely.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Prerequisites and values to collect

Before creating the service, identify the following values for your application:

  • The Linux account that will own and run the application, for example appuser. Do not use root.
  • The absolute application directory, for example /srv/myapp.
  • The Python import path for the WSGI callable. Typical forms are project.wsgi:application or myapp:app; use the form required by your framework.
  • The virtual-environment directory, for example /srv/myapp/.venv.
  • The account and group used by Nginx on this VPS. Verify them on the host rather than assuming a distribution default.
  • A socket name that is unique on the server, such as /run/uwsgi/myapp.sock.

Ubuntu release, Python version, framework, and package availability affect the installation command. Confirm those details for the target release before installing operating-system packages; this guide does not assume a particular Ubuntu version or Python compatibility matrix.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create a non-root application account and virtual environment

Create an account with only the access it needs

Create a dedicated deployment account using your organisation’s approved Ubuntu account-management procedure, then give it ownership of the application files it must read or write. Keep secrets and writable upload directories separate where possible. The account should not be used for unrelated services.

Do not run uWSGI or the application as root. If a deployment step needs administrative rights, perform that step with sudo, then return ownership of runtime files to the service account.

Create and activate the virtual environment

cd /srv/myapp
python3 -m venv .venv
. .venv/bin/activate

The exact Python executable may differ on your Ubuntu release. The important property is that the environment used to install uWSGI is the same environment referenced by the service configuration.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Install the application dependencies and uWSGI inside this environment using the dependency method supported by your project. Then confirm the executable that systemd will run:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
which uwsgi

Record the absolute path printed by which uwsgi. Do not substitute a different system-wide binary in the unit file; a mismatch is a common cause of imports and plugins working in a shell but failing under systemd.

Prove that the application imports before involving Nginx

Run the application’s import check while the virtual environment is active. The check must exercise the same module path you will put in the uWSGI INI file. If the import fails here, fix the dependency, working-directory, settings, or environment-variable problem first. Nginx cannot repair an application that uWSGI cannot import.

Keep the application directory and virtual-environment paths absolute in production configuration. Relative paths can resolve differently when a process is started by systemd rather than from an interactive shell.

Write the uWSGI INI file

Create an INI file owned by the deployment account in a configuration directory that the service can read, for example /etc/uwsgi/apps-available/myapp.ini if that layout is already used on your host. The filename and directory are your choice; the systemd unit must reference the exact file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
[uwsgi]
chdir = /srv/myapp
module = project.wsgi:application
home = /srv/myapp/.venv
master = true
processes = 2
socket = /run/uwsgi/myapp.sock
chmod-socket = 660
vacuum = true
die-on-term = true

Replace the example module, directories, socket name, and worker count with values for your application.

What each setting does

  • chdir sets the working directory before the application module is imported.
  • module identifies the Python module and WSGI callable. The import path must match the application.
  • home points uWSGI at the virtual environment that contains the application and uWSGI installation.
  • master = true enables the uWSGI master process, which manages workers.
  • processes sets the initial worker count. Size it for the VPS and application workload; do not copy a number blindly from another server. More workers consume more memory.
  • socket is the endpoint Nginx will use. The path must match the Nginx configuration character for character.
  • chmod-socket gives the socket a mode that can allow the Nginx group to connect. Pair it with an intentional group and filesystem policy; do not make the socket world-writable.
  • vacuum = true asks uWSGI to remove its socket when it exits, reducing stale-socket confusion.
  • die-on-term = true lets a normal service stop signal terminate uWSGI cleanly under systemd.

The socket directory itself must exist at runtime. The systemd unit below uses RuntimeDirectory=uwsgi where supported, creating /run/uwsgi when the service starts. If your target systemd version does not support that directive, create the directory with an equivalent, boot-safe mechanism and apply the same ownership policy.

Create a systemd unit for uWSGI

Save a unit such as /etc/systemd/system/myapp-uwsgi.service. Use the account and group that should run this application, and replace the executable path with the result of which uwsgi.

[Unit]
Description=uWSGI service for myapp
After=network.target

[Service]
Type=notify
User=appuser
Group=appuser
RuntimeDirectory=uwsgi
RuntimeDirectoryMode=0750
WorkingDirectory=/srv/myapp
ExecStart=/srv/myapp/.venv/bin/uwsgi --ini /etc/uwsgi/apps-available/myapp.ini
Restart=on-failure

[Install]
WantedBy=multi-user.target

uWSGI documentation describes uWSGI as a new-style daemon for systemd. Type=notify allows systemd to track readiness when the installed uWSGI build supports systemd notifications. Restart=on-failure requests recovery from an unexpected exit without turning a deliberate stop into an immediate restart.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make the socket reachable by Nginx without making it public

The service account owns the runtime directory by default. Nginx also needs permission to connect to the socket. Choose one of these least-privilege arrangements:

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
  • Run the uWSGI service with a group that includes the Nginx account, and set the socket mode to allow group access.
  • Use an explicit socket owner/group setting supported by your uWSGI build, assigning the socket to the Nginx group while keeping the process itself under the application uid.
  • Use a dedicated shared group for the two services and grant only the required directory traversal and socket-connect permissions.

After startup, inspect the actual owner, group, and mode. Never assume that a syntactically valid unit produced the permissions you intended.

Enable, start, and inspect the service

  1. Ask systemd to reread unit files: sudo systemctl daemon-reload.
  2. Start the service: sudo systemctl start myapp-uwsgi.service.
  3. Inspect the result immediately: sudo systemctl status myapp-uwsgi.service.
  4. Inspect recent service messages: sudo journalctl -u myapp-uwsgi.service -n 100 --no-pager.
  5. Confirm that the socket exists and has the expected mode: ls -l /run/uwsgi/myapp.sock.
  6. Once the service is healthy, enable it at boot: sudo systemctl enable myapp-uwsgi.service.

Perform the status and journal checks after every unit or INI change. A service that is enabled but currently failed will still fail after the next reboot; enabling is not a health check.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Point Nginx at the same socket

In the appropriate Nginx server block, pass requests to the Unix socket:

location / {
    include uwsgi_params;
    uwsgi_pass unix:/run/uwsgi/myapp.sock;
}

The include uwsgi_params; line supplies the request variables expected by a WSGI application. The uwsgi_pass path must be identical to the socket value in the uWSGI INI file.

If you intentionally choose loopback TCP instead, configure the same port on both sides. The documented Nginx pattern is:

location / {
    include uwsgi_params;
    uwsgi_pass localhost:9000;
}

Keep that listener on loopback unless there is a deliberate, reviewed reason to expose it on another interface. A TCP choice does not remove the need for service-user isolation and firewall policy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Validate Nginx before reloading it

Use your host’s normal Nginx configuration-test and reload procedure. Check Nginx’s error log after the reload and after the first request. Permission errors, a missing socket, a stale path, and an upstream-protocol mismatch are more useful clues than a generic browser error page.

Test from the VPS before opening public access

  1. Confirm the uWSGI unit is active with systemctl status myapp-uwsgi.service.
  2. Confirm the socket path, owner, group, and mode with ls -l /run/uwsgi/.
  3. Make a local HTTP request through Nginx, using the server name configured in the Nginx server block.
  4. Check the uWSGI journal and Nginx error log for the same request.
  5. Only after local success, apply the VPS provider’s firewall policy and publish the site with TLS.

This order separates application failures from DNS, firewall, and certificate problems. It also prevents a publicly reachable Nginx endpoint from masking a broken private upstream.

Troubleshoot by symptom

Symptom Likely check Corrective action
systemd reports that the executable cannot be found The absolute path in ExecStart versus which uwsgi inside the virtual environment Use the environment’s actual uWSGI path, then run systemctl daemon-reload and restart the unit.
uWSGI exits while importing the application Module path, chdir, dependencies, and environment variables Activate the same virtual environment and reproduce the import manually; fix the first Python traceback before changing Nginx.
Nginx returns a gateway error and the socket is absent Service status and journal Resolve the uWSGI startup failure. Confirm that RuntimeDirectory=uwsgi is supported and that the service reached the socket-creation stage.
Nginx reports permission denied on the socket ls -l /run/uwsgi/myapp.sock and directory traversal permissions Align the socket group/mode with the Nginx account. Do not solve it by making the socket world-writable.
Nginx reports no such file or directory Character-for-character comparison of both socket paths Correct either the INI or Nginx configuration, restart uWSGI if needed, and test again.
The service works manually but not after reboot Unit enablement, runtime-directory creation, and absolute paths Confirm the unit is enabled, avoid shell-only environment assumptions, and inspect the boot-time journal.
Requests reach uWSGI but the application returns an upstream-protocol error Nginx location block and the use of uwsgi_pass Ensure the block includes uwsgi_params and uses the uWSGI protocol directive rather than a generic HTTP proxy directive.

Run several applications with Emperor mode

For multiple applications, run an Emperor that watches a vassals directory. Each vassal file describes one application and should specify its own working directory, virtual environment, socket, uid, and gid. Keep sockets distinct; two vassals cannot safely claim the same endpoint.

The documented Emperor behavior is intentionally simple: a new configuration file spawns a vassal, a modified file reloads its application, and a removed file stops it. Treat changes to that directory as production changes and review ownership so an untrusted account cannot create or modify vassal definitions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The uWSGI systemd guide warns: Do not daemonize the Emperor (or the master) unless you know what you are doing!!! Let systemd supervise the foreground process. Adding a second daemonization layer can hide the process from systemd and defeat restart and status reporting.

Operational and security checklist

  • Run the application and uWSGI under a dedicated non-root account.
  • Use the same virtual environment for dependency installation, import testing, and ExecStart.
  • Use absolute paths for the application directory, INI file, virtual environment, executable, and socket.
  • Keep the socket under /run/uwsgi/ or another runtime directory that is not publicly served.
  • Grant Nginx only the group and directory access required to connect to the socket.
  • Bind TCP only to loopback unless a documented architecture requires otherwise.
  • Inspect systemctl status, the service journal, and Nginx error logs after each change.
  • Choose worker counts according to the VPS memory and application behavior; monitor before increasing them.
  • Test locally through Nginx before changing DNS, firewall exposure, or TLS settings.
  • Apply TLS and firewall rules appropriate to the VPS provider only after the private path is healthy.

When to choose a different design

A standalone systemd unit is the clearest option for one application on one VPS. Emperor is useful when the host intentionally runs several uWSGI applications and you want file-driven vassal lifecycle management. A Unix socket is the least surprising local hand-off; loopback TCP is reasonable when another local component specifically requires a port. Containerized deployment involves packaging and host-integration trade-offs that are separate from this systemd-and-Nginx procedure, so do not mix the two supervision models accidentally.

Final verification sequence

  1. The application imports successfully from its own virtual environment.
  2. which uwsgi identifies the binary used by the systemd unit.
  3. The INI module, working directory, virtual environment, worker count, and socket are correct.
  4. The unit uses Type=notify, an appropriate restart policy, and RuntimeDirectory=uwsgi where supported.
  5. systemctl status shows an active service and the journal has no startup traceback.
  6. The socket exists under /run/uwsgi/ with the intended owner, group, and mode.
  7. Nginx includes uwsgi_params and points to that exact socket or intentionally firewalled loopback port.
  8. A local request succeeds before public DNS, TLS, and firewall exposure are changed.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.