Troubleshooting
Solutions for common CSP configuration issues.
Reports Not Appearing
Section titled “Reports Not Appearing”Check Your Header
Section titled “Check Your Header”Verify the CSP header is being sent:
curl -I https://your-site.com | grep -i content-security-policyYou should see either Content-Security-Policy or Content-Security-Policy-Report-Only.
Verify the Report URI
Section titled “Verify the Report URI”Ensure your report-uri directive is correct:
report-uri https://ingest.headerhawk.com/csp/YOUR_SITE_IDCommon mistakes:
- Missing
https:// - Wrong site ID
- Typo in the domain name
Test Manually
Section titled “Test Manually”Send a test report:
curl -X POST \ https://ingest.headerhawk.com/csp/YOUR_SITE_ID \ -H "Content-Type: application/csp-report" \ -d '{"csp-report":{"document-uri":"https://test.com","violated-directive":"test"}}'A 204 No Content response means it worked.
Browser Console
Section titled “Browser Console”Check the browser console for CSP messages. Violations appear as warnings even in report-only mode.
Site Breaking After Adding CSP
Section titled “Site Breaking After Adding CSP”Start with Report-Only
Section titled “Start with Report-Only”Always use Content-Security-Policy-Report-Only first:
Content-Security-Policy-Report-Only: default-src 'self'; report-uri https://ingest.headerhawk.com/csp/YOUR_SITE_IDThis reports violations without blocking anything.
Common Resources That Break
Section titled “Common Resources That Break”| Issue | Solution |
|---|---|
| Inline scripts blocked | Add 'unsafe-inline' or use nonces |
| CDN scripts blocked | Add the CDN domain to script-src |
| Google Fonts blocked | Add fonts.googleapis.com and fonts.gstatic.com |
| Images not loading | Add domains to img-src or use https: |
| API calls failing | Add API domain to connect-src |
Finding Blocked Resources
Section titled “Finding Blocked Resources”- Open browser DevTools
- Go to the Console tab
- Look for “Refused to…” messages
- Note the blocked URL and violated directive
Too Many Reports
Section titled “Too Many Reports”Reduce Noise
Section titled “Reduce Noise”Some violations are expected or from browser extensions. Filter in Header Hawk dashboard by:
- Document host (your domains only)
- Blocked host (exclude known extension domains)
- Directive (focus on critical directives)
Common False Positives
Section titled “Common False Positives”| Source | Cause | Action |
|---|---|---|
chrome-extension:// | Browser extensions | Filter out in dashboard |
moz-extension:// | Firefox extensions | Filter out in dashboard |
about:blank | Injected iframes | Usually safe to ignore |
localhost | Dev tools or extensions | Filter out in dashboard |
Switching to Enforce Mode
Section titled “Switching to Enforce Mode”Pre-Switch Checklist
Section titled “Pre-Switch Checklist”- Run in report-only mode for at least a week
- Review all violation types in the dashboard
- Add legitimate resources to your policy
- Test critical user flows
- Have a rollback plan
Making the Switch
Section titled “Making the Switch”Change the header from:
Content-Security-Policy-Report-Only: ...To:
Content-Security-Policy: ...Keep the report-uri to continue receiving reports about enforced blocks.
Rollback Plan
Section titled “Rollback Plan”If things break:
- Immediately revert to
Content-Security-Policy-Report-Only - Check new violations in the dashboard
- Update policy to allow legitimate resources
- Try enforcing again
Specific Issues
Section titled “Specific Issues”Inline Scripts
Section titled “Inline Scripts”Problem: Refused to execute inline script
Solutions:
- Move to external file (recommended)
- Use nonce:
Content-Security-Policy: script-src 'nonce-abc123'<script nonce="abc123">...</script>
- Use hash:
Content-Security-Policy: script-src 'sha256-...'
- Allow unsafe-inline (not recommended):
Content-Security-Policy: script-src 'unsafe-inline'
Inline Styles
Section titled “Inline Styles”Problem: Refused to apply inline style
Solutions:
- Move styles to external CSS file
- Use
'unsafe-inline'for styles (lower risk than scripts):Content-Security-Policy: style-src 'self' 'unsafe-inline'
eval() and Function()
Section titled “eval() and Function()”Problem: Refused to evaluate a string as JavaScript
Cause: Your code or a library uses eval(), new Function(), or similar.
Solutions:
- Replace with safer alternatives
- If unavoidable, add
'unsafe-eval'(security risk):Content-Security-Policy: script-src 'unsafe-eval'
WebSocket Connections
Section titled “WebSocket Connections”Problem: WebSocket connection refused
Solution: Add to connect-src:
Content-Security-Policy: connect-src 'self' wss://your-websocket-server.comFrames and Embeds
Section titled “Frames and Embeds”Problem: Cannot load content in iframe
Solution: Add source to frame-src:
Content-Security-Policy: frame-src 'self' https://youtube.com https://player.vimeo.comGetting Help
Section titled “Getting Help”If you’re stuck:
- Check the browser console for specific error messages
- Review violations in the Header Hawk dashboard
- Search for the specific directive and error message
- Test with a minimal policy and add directives incrementally