Django + Tailwind CSS deployment failing on Railway with Procfile parsing errors
I'm trying to deploy a Django application with compiled Tailwind CSS to Railway, but I keep getting Procfile parsing errors. The build process works fine (Tailwind compiles successfully), but the deployment fails during the Procfile parsing stage.
Error Message
Nixpacks build failed
Error: Reading Procfile
Caused by:
found unknown escape character at line 1 column 44, while parsing a quoted scalar
My Setup
Project Structure:
Jobflow/
├── manage.py
├── Procfile
├── requirements.txt
├── package.json
├── tailwind.config.js
├── static/
│ └── css/
│ ├── input.css
│ └── output.css (generated)
├── Jobflow/
│ ├── settings.py
│ ├── wsgi.py
│ └── urls.py
└── JobFlow_app/
├── models.py
├── views.py
└── templates/
Current Procfile content:
web: python manage.py runserver 0.0.0.0:$PORT
requirements.txt:
Django==4.2
python-decouple==3.8
gunicorn==21.2.0
whitenoise==6.6.0
psycopg2-binary==2.9.9
Pillow==10.1.0
dj-database-url==2.1.0
package.json scripts:
{
"scripts": {
"build-css": "npx tailwindcss -i ./static/css/input.css -o ./static/css/output.css --watch",
"build-css-prod": "npx tailwindcss -i ./static/css/input.css -o ./static/css/output.css --minify",
"dev": "npm run build-css",
"build": "npm run build-css-prod"
},
"devDependencies": {
"tailwindcss": "^3.4.0"
}
}
What Works
✅ Tailwind CSS compilation - Build logs show:
> npx tailwindcss -i ./static/css/input.css -o ./static/css/output.css --minify
Rebuilding...
Done in 417ms.
✅ Python dependencies installation - No errors during pip install
✅ Static file structure - All files are in the correct locations
What I've Tried
1. Different Procfile formats:
web: gunicorn Jobflow.wsgi:application --bind 0.0.0.0:$PORT
web: gunicorn Jobflow.wsgi --bind 0.0.0.0:$PORT
web: python -m gunicorn Jobflow.wsgi:application --bind 0.0.0.0:$PORT
web: python manage.py runserver 0.0.0.0:$PORT
2. File creation methods:
# Using echo command
echo "web: python manage.py runserver 0.0.0.0:$PORT" > Procfile
# Using here document
cat > Procfile << 'EOF'
web: python manage.py runserver 0.0.0.0:$PORT
EOF
- Creating manually in VS Code
3. Railway configuration:
- Tried with and without railway.toml
- Tried with and without nixpacks.toml
- Added PostgreSQL database
- Set environment variables (SECRET_KEY, DEBUG=False, etc.)
Build Logs (Successful Parts)
[stage-0 6/12] RUN npm ci ✔ 2 sec
[stage-0 8/12] RUN npm run build
> jobflow@1.0.0 build
> npm run build-css-prod
> npx tailwindcss -i ./static/css/input.css -o ./static/css/output.css --minify
Rebuilding...
Done in 417ms. ✔ 1 sec
What I Tried and Expected Results
1. Standard Gunicorn Deployment
Attempt:
web: gunicorn Jobflow.wsgi:application --bind 0.0.0.0:$PORT
Expected: Standard Django production deployment with Gunicorn
Result: gunicorn: command not found errors
2. Django Development Server
Attempt:
web: python manage.py runserver 0.0.0.0:$PORT
Expected: Should work since Django is definitely installed
Result: Same parsing error - found unknown escape character at line 1 column 44
3. File Creation Methods Tried
Method A - Echo command:
echo "web: python manage.py runserver 0.0.0.0:$PORT" > Procfile
Method B - Here document:
cat > Procfile << 'EOF'
web: python manage.py runserver 0.0.0.0:$PORT
EOF
Method C - Manual creation in VS Code:
- Created new file named exactly Procfile (no extension)
- Typed content manually: web: python manage.py runserver 0.0.0.0:$PORT
- Saved with UTF-8 encoding
Result: All methods show same error: found unknown escape character at line 1 column 44
4. Port Variable Testing
Tried different PORT syntax:
$PORT (standard)
${PORT} (bash expansion)
8000 (hardcoded for testing)
Result: All variations still show parsing error at column 44
Environment
- Platform: Railway
- Build system: Nixpacks
- Django version: 4.2
- Python version: 3.11 (Railway default)
- Local development: Windows 11, works perfectly
Questions
- Why does Railway's Procfile parser think there are escape characters when my file contains plain text?
- Is there a Railway-specific Procfile format I should be using?
- Could the issue be related to having both Node.js (for Tailwind) and Python dependencies?
- What's the proper way to deploy Django + Tailwind CSS to Railway?
The Mystery
- Column 44 would be around the $PORT variable in my Procfile
- But I've tried every possible variation and file creation method
- The exact same Procfile format works for other developers on Railway
- Local development works perfectly with the same Django setup
This suggests there's something specific about my setup causing Railway's Procfile parser to fail.
do you have a .toml file for your nixpacks?