Overview
PythonAnywhere is a Python-focused Platform-as-a-Service (PaaS) that simplifies Django deployment. OSINT Hub includes a pre-configured WSGI file (pythonanywhere_wsgi.py) specifically designed for PythonAnywhere.
Prerequisites
- PythonAnywhere account (free or paid)
- Basic familiarity with the PythonAnywhere dashboard
- OSINT Hub repository access
Deployment Steps
Create a PythonAnywhere account
Sign up at https://www.pythonanywhere.comChoose a username - this will be part of your app URL:
https://YOUR_USERNAME.pythonanywhere.comOpen a Bash console
From your PythonAnywhere dashboard:
- Click on Consoles tab
- Click Bash to start a new console session
Create a virtual environment
PythonAnywhere requires virtual environments in The environment will be automatically activated. To activate it later:
~/.virtualenvs/:Configure environment variables
Create a Update with your PythonAnywhere-specific settings:Generate a secure Replace
.env file:SECRET_KEY:YOUR_USERNAME with your actual PythonAnywhere username.Web App Configuration
Create a new web app
From your PythonAnywhere dashboard:
- Click on the Web tab
- Click Add a new web app
- Choose Manual configuration (not Django wizard)
- Select Python 3.12
Configure source code directory
In the Code section:Source code:
/home/YOUR_USERNAME/osint_hubReplace YOUR_USERNAME with your PythonAnywhere username.Configure virtual environment
In the Virtualenv section:Enter path to a virtualenv:
/home/YOUR_USERNAME/.virtualenvs/osint_hub_envClick the checkmark to save.Configure WSGI file
In the Code section, click on the WSGI configuration file link (e.g., Important: Replace
/var/www/YOUR_USERNAME_pythonanywhere_com_wsgi.py).Delete all the default content and replace it with the contents of pythonanywhere_wsgi.py:YOUR_USERNAME with your actual PythonAnywhere username (appears twice in the file).Click Save at the top of the editor.Configure static files
In the Static files section, add the following mapping:
Click the checkmark to save.
| URL | Directory |
|---|---|
/static/ | /home/YOUR_USERNAME/osint_hub/staticfiles/ |
Reload the web app
At the top of the Web tab, click the green Reload YOUR_USERNAME.pythonanywhere.com button.Wait for the reload to complete (typically 10-20 seconds).
PythonAnywhere-Specific Considerations
HTTP Request Whitelist
PythonAnywhere free accounts restrict outbound HTTP requests to whitelisted sites only. Some OSINT tools may not work properly. Affected tools:- Email Search (Holehe) - may have limited results
- Username Search (Sherlock) - may have limited results
- IP Lookup - uses whitelisted APIs (should work)
No Background Tasks (Free Accounts)
Free PythonAnywhere accounts don’t support long-running background processes like Celery. Impact:- Phone Search async tasks won’t work properly
- Some tools may time out on larger searches
- Upgrade to a paid account to enable scheduled tasks and always-on tasks
- Modify views to run synchronously (not recommended for long operations)
File Size Limits
PythonAnywhere has disk quota limits:- Free: 512 MB total disk space
- Paid: Varies by plan
- Periodically clean up uploaded files in
media/ - Limit EXIF tool file uploads to essential files only
- Monitor disk usage in the Files tab
Database Limitations
SQLite (default) works well for small to medium traffic. For high traffic, consider:- Upgrading to a paid account with MySQL/PostgreSQL support
- Configuring a remote PostgreSQL database
Environment Variables in PythonAnywhere
PythonAnywhere doesn’t natively support.env files in the WSGI context. The pythonanywhere_wsgi.py file is already configured to load from .env via python-decouple.
Alternative: Set in WSGI file
You can also set environment variables directly in the WSGI file:Troubleshooting
”ImportError” or “ModuleNotFoundError”
Cause: Dependencies not installed or virtual environment not activated. Solution:Static files not loading (404 errors)
Cause: Static files not collected or incorrect path mapping. Solution:- URL:
/static/ - Directory:
/home/YOUR_USERNAME/osint_hub/staticfiles/
”DisallowedHost” error
Cause:ALLOWED_HOSTS in .env doesn’t include your PythonAnywhere domain.
Solution:
Edit .env:
”CSRF verification failed”
Cause:CSRF_TRUSTED_ORIGINS not configured correctly.
Solution:
Edit .env:
Tools not working (HTTP request errors)
Cause: PythonAnywhere whitelist restrictions (free accounts). Solution:- Upgrade to a paid account for unrestricted access
- Check the PythonAnywhere whitelist: https://www.pythonanywhere.com/whitelist/
Error logs
View error logs in the Web tab:- Click on Log files
- Check Error log for Python exceptions
- Check Server log for HTTP errors
Updates and Maintenance
Custom Domain (Paid Accounts)
Paid PythonAnywhere accounts support custom domains.Performance Optimization
Database Indexing
For better query performance:Caching
Consider implementing Django caching for frequently accessed data:Static File Compression
WhiteNoise automatically compresses static files. Ensure it’s enabled insettings.py (already configured):
Security Considerations
- Always set
DEBUG=Falsein production - Use a strong, randomly generated
SECRET_KEY - Regularly update dependencies:
pip list --outdated - Monitor error logs for suspicious activity
- Keep your PythonAnywhere account password secure
- Enable two-factor authentication on your PythonAnywhere account
Next Steps
- Configure Environment Variables
- Production Deployment Guide
- Check PythonAnywhere documentation: https://help.pythonanywhere.com/
