Python / Uvicorn Fundamentals Interview Questions
What are Uvicorn's default host, port, and log level settings?
Uvicorn's defaults are chosen to be safe for local development - binding only to localhost prevents accidental external exposure, while the info log level provides useful startup and access log output without being overwhelming.
| Setting | Default value | Notes |
|---|---|---|
| --host | 127.0.0.1 | Loopback only - not reachable from other machines |
| --port | 8000 | Standard development port |
| --log-level | info | Options: critical, error, warning, info, debug, trace |
| --workers | 1 | Single process - use WEB_CONCURRENCY env var or --workers for more |
| --loop | auto | Prefers uvloop if installed, falls back to asyncio |
| --http | auto | Prefers httptools if installed, falls back to h11 |
| --ws | auto | Prefers websockets if installed, falls back to wsproto |
| --lifespan | auto | Enables lifespan if supported by the application |
| --proxy-headers | enabled | Trusts X-Forwarded-* headers from 127.0.0.1 |
# To make the server externally accessible (development/testing): uvicorn main:app --host 0.0.0.0 # Production: always specify host explicitly uvicorn main:app --host 0.0.0.0 --port 8000 # Check what's running: curl http://127.0.0.1:8000/ # The WEB_CONCURRENCY environment variable sets default worker count export WEB_CONCURRENCY=4 uvicorn main:app # will start 4 workers
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
