Skip to content

Troubleshooting

Solutions for common CSP configuration issues.

Verify the CSP header is being sent:

Terminal window
curl -I https://your-site.com | grep -i content-security-policy

You should see either Content-Security-Policy or Content-Security-Policy-Report-Only.

Ensure your report-uri directive is correct:

report-uri https://ingest.headerhawk.com/csp/YOUR_SITE_ID

Common mistakes:

  • Missing https://
  • Wrong site ID
  • Typo in the domain name

Send a test report:

Terminal window
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.

Check the browser console for CSP messages. Violations appear as warnings even in report-only mode.

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_ID

This reports violations without blocking anything.

IssueSolution
Inline scripts blockedAdd 'unsafe-inline' or use nonces
CDN scripts blockedAdd the CDN domain to script-src
Google Fonts blockedAdd fonts.googleapis.com and fonts.gstatic.com
Images not loadingAdd domains to img-src or use https:
API calls failingAdd API domain to connect-src
  1. Open browser DevTools
  2. Go to the Console tab
  3. Look for “Refused to…” messages
  4. Note the blocked URL and violated directive

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)
SourceCauseAction
chrome-extension://Browser extensionsFilter out in dashboard
moz-extension://Firefox extensionsFilter out in dashboard
about:blankInjected iframesUsually safe to ignore
localhostDev tools or extensionsFilter out in dashboard
  1. Run in report-only mode for at least a week
  2. Review all violation types in the dashboard
  3. Add legitimate resources to your policy
  4. Test critical user flows
  5. Have a rollback plan

Change the header from:

Content-Security-Policy-Report-Only: ...

To:

Content-Security-Policy: ...

Keep the report-uri to continue receiving reports about enforced blocks.

If things break:

  1. Immediately revert to Content-Security-Policy-Report-Only
  2. Check new violations in the dashboard
  3. Update policy to allow legitimate resources
  4. Try enforcing again

Problem: Refused to execute inline script

Solutions:

  1. Move to external file (recommended)
  2. Use nonce:
    Content-Security-Policy: script-src 'nonce-abc123'
    <script nonce="abc123">
    ...
    </script>
  3. Use hash:
    Content-Security-Policy: script-src 'sha256-...'
  4. Allow unsafe-inline (not recommended):
    Content-Security-Policy: script-src 'unsafe-inline'

Problem: Refused to apply inline style

Solutions:

  1. Move styles to external CSS file
  2. Use 'unsafe-inline' for styles (lower risk than scripts):
    Content-Security-Policy: style-src 'self' 'unsafe-inline'

Problem: Refused to evaluate a string as JavaScript

Cause: Your code or a library uses eval(), new Function(), or similar.

Solutions:

  1. Replace with safer alternatives
  2. If unavoidable, add 'unsafe-eval' (security risk):
    Content-Security-Policy: script-src 'unsafe-eval'

Problem: WebSocket connection refused

Solution: Add to connect-src:

Content-Security-Policy: connect-src 'self' wss://your-websocket-server.com

Problem: Cannot load content in iframe

Solution: Add source to frame-src:

Content-Security-Policy: frame-src 'self' https://youtube.com https://player.vimeo.com

If you’re stuck:

  1. Check the browser console for specific error messages
  2. Review violations in the Header Hawk dashboard
  3. Search for the specific directive and error message
  4. Test with a minimal policy and add directives incrementally