This guide helps you debug Railway deployment issues locally using the Railway CLI.
-
Find your service name:
- Go to your Railway dashboard: https://railway.app
- Open your project "neetme"
- Look at the services list - common names are:
web,api,neetme, or similar - The service name is usually shown in the service card/title
-
Use the debug script:
# Check recent logs ./scripts/debug-railway.sh logs <service-name> # Test build with Railway environment ./scripts/debug-railway.sh build <service-name> # Test start command with Railway environment ./scripts/debug-railway.sh start <service-name> # Show environment variables (masked) ./scripts/debug-railway.sh env <service-name>
If you prefer to run commands manually:
# View logs
railway logs -s <service-name> --tail 100
# Run build with Railway environment
railway run -s <service-name> npm run build
# Run start command with Railway environment
railway run -s <service-name> npm start
# Check environment variables (without values)
railway run -s <service-name> env | grep -E "^(DATABASE_URL|NEXT_PUBLIC_|NEXTAUTH_|NODE_ENV)"- Run:
railway run -s <service-name> npm run build - Check for missing dependencies or TypeScript errors
- Verify
nixpacks.tomlconfiguration
- Run:
railway run -s <service-name> npm start - Check if
.next/standalonedirectory exists after build - Verify
server.jsexists in standalone directory
- Check
DATABASE_URLenvironment variable is set - Verify PostgreSQL service is running in Railway
- Test connection:
railway run -s <service-name> npx prisma db push
- Check Railway dashboard → Variables tab
- Required variables:
DATABASE_URL(auto-set by PostgreSQL service)NEXT_PUBLIC_REOWN_PROJECT_IDNEXT_PUBLIC_APP_URLNEXTAUTH_URLNEXTAUTH_SECRETNODE_ENV=production
- Railway automatically sets
PORTenvironment variable - Your app should use
process.env.PORT || 3000 - Check if Next.js standalone server respects PORT
-
Pull Railway environment and test build:
railway run -s <service-name> npm run build
-
Test the start command:
railway run -s <service-name> npm start
This will start your app locally with Railway's environment variables.
-
Check for errors:
- Look for database connection errors
- Check for missing environment variables
- Verify the standalone build structure
After identifying the issue:
- Fix the problem locally
- Commit and push to GitHub
- Railway will automatically redeploy
- Monitor logs:
railway logs -s <service-name> --tail 100
- Railway Dashboard: https://railway.app
- Railway Docs: https://docs.railway.com
- Check build logs in Railway dashboard
- Check runtime logs:
railway logs -s <service-name>