WordPress troubleshooting

Common setup issues with WordPress OneSignal Web Push Setup (Chrome, Firefox, Safari)

If you are not using the OneSignal WordPress plugin see our Troubleshooting Web Push Guide.

Common setup issues

OneSignal dashboard setup

Return to the WordPress setup docs and make sure you followed all direction.

  • You must select the WordPress Plugin option in your onesignal.com dashboard.
  • Your Site URL must match what you see in the browser. https://yoursite.com is different from https://www.yoursite.com make sure to set the one you see in the browser when visiting your site.
    • If you use both www and non-www versions, then choose one to setup with OneSignal. You can only subscribe users on one domain aka site origin. See the Same-origin policy for more details.
  • Check your permission prompts. Make sure you added at least one push prompt to subscribe users.

Do not add the OneSignal init code

You can add our Web SDK methods for additional functionality, but DO NOT use any additional initialization code. Our WordPress plugin adds the initialization code for OneSignal and Service Worker to your site.

There is no code you need to add to the init call. If you want to customize initialization with code, see our Custom Code Setup and remove the WordPress plugin.


How to troubleshoot your site

  1. Visit your website with the OneSignal WordPress plugin active. Do not use incognito or private browser mode. This example uses Chrome.

  2. Right-click the page and press Inspect

  3. Open the Console tab.

    Right-click your site, click Inspect, open the Console.

    Right-click your site, click Inspect, open the Console.

  4. Refresh the page and check for OneSignal errors. See Common OneSignal Console errors if you see any.

  5. If you don't see any errors copy-paste this code into the console:
    OneSignal.User.PushSubscription.id
    You should see a Subscription ID like this:

    How to find your OneSignal Subscription ID.

    How to find your OneSignal Subscription ID.

  6. Go into your onesignal.com dashboard > Audience > Subscriptions page and search for your Subscription ID.

    How to search the OneSignal dashboard for your Subscription ID.

    How to search the OneSignal dashboard for your Subscription ID.

  7. If you see the status is Subscribed then you should be able to receive push notifications. Follow Push guide to send a push. If you don't get it, make sure push is enabled for your browser in the operating system. See Web push: Notifications not shown for details.


📘

Still having issues?

Contact [email protected] and share:

  1. the site URL you tested on.
  2. screenshots following the steps above.

Common OneSignal Console errors

SdkInitError: OneSignal: This web push config can only be used on ... Your current origin is ...

This means the site URL you set in the your OneSignal dashboard is different from the current site URL in the browser. You must use a single site origin for your site https://your-site.com is different from https://www.your-site.com. See WordPress setup for details.

PushPermissionNotGrantedError: The user dismissed the permission prompt.

The user dismissed the permission prompt, you will need to wait for the backoff period to display again. See Web permission prompts for details.

You can clear browser data to quickly try again.

The OneSignal web SDK can only be initialized once.

Our WordPress plugin automatically adds the needed initialization code to your site. Search your site for the OneSignal code you added and remove it.

Installing service worker failed.. 403 or 404 error

In you see 403 or 404 Service Worker Errors, that means something is blocking the following files from being publicly accessible:

https://your-site.com/wp-content/plugins/onesignal-free-web-push-notifications/sdk_files/OneSignalSDKWorker.js

See the below Common plugin support options that should fix this.

Common plugin support

Using caching plugins with CDN support can cause files required to be served from your domain to be served from the CDN instead. Here's how to use the appropriate settings:

Autoptimize

In Excluded scripts section, exclude the OneSignal Script:

wp-content/plugins/onesignal-free-web-push-notifications/sdk_files/(.*)

WP Rocket

In the WP Rocket CDN settings, under "Exclude Files From CDN" add the following line:

(.*)/onesignal-free-web-push-notifications/sdk_files/(.*)

Then press save.

LiteSpeed Cache

In the LiteSpeed CDN settings, under "Exclude Path" add the following line:

(.*)/onesignal-free-web-push-notifications/sdk_files/(.*)

Then press save.

WP Super Cache

  1. Log in to your WordPress admin panel and visit Settings > WP Super Cache.

  2. Click the CDN tab.

  3. Make sure the Exclude if substring tab has at least the following contents: .php, onesignal-free-web-push-notifications. You can have more than this, but you must have at least these two entries.

  4. Click the Contents tab.

  5. Click the Delete Cache button.

  6. The required files should now be served from your domain. Refresh your site page.

WP Engine

In your WP Engine plugin > General Settings > HTML Post-Processing

add the below URLs replacing "YOURSITEHERE" with your website:

#https?://(www\.)?(YOURSITEHERE\.com|mywpenginehandleHere.wpengine.com|wpengineCDNpathHere.wpengine.netdna-(ssl|cdn).com)/wp-(content|includes)# => https://wpengineCDNpathHere-wpengine.netdna-ssl.com/wp-$4
#https://wpengineCDNpathHere-wpengine.netdna-ssl.com/plugins/onesignal-free-web-push-notifications/# => https://mywebsiteHere.com/wp-content/plugins/onesignal-free-web-push-notifications/
#https://wpengineCDNpathHere-wpengine.netdna-ssl.com/wp-content/plugins/onesignal-free-web-push-notifications/# => https://mywebsiteHere.com/wp-content/plugins/onesignal-free-web-push-notifications/

W3 Total Cache

  1. Log in to your WordPress admin panel and click Performance on the left sidebar.

  2. Click the CDN tab.

  3. Find the textbox for "Rejected files".

  4. Add an entry for {plugins_dir}/onesignal-free-web-push-notifications/sdk_files/*

  5. Click Save all settings.

BunnyCDN

Add *onesignal* to the excluded paths in the Bunny > CDN section of the plugin.

Once that's saved, purge the HTML cache if you're using any HTML caching plugin such as WP Total Cache.

CDN Enabler

  1. Log in to your WordPress admin panel and click Settings -> CDN Enabler on the left sidebar.

  2. Find the "Exclusions" textbox.

  3. Add "onesignal-free-web-push-notifications".

    Your textbox might look like ".php,onesignal-free-web-push-notifications".

  4. Click Save Changes.

PressCDN

In the PressCDN settings under Exclude Directories add: /wp-content/plugins/onesignal-free-web-push-notifications/

Breeze

In Breeze > Settings > CDN > Exclude Content add /onesignal-free-web-push-notifications/sdk_files/

Hummingbird Pro

In Hummingbird Pro > Asset Optimization find "remote_sdk" with "OneSignalSDK.js#asyncload"

Select that file and remove from Optimization.

Then reset any cache plugins and return to the site.

Sucuri

Sucuri provides an option in its settings to whitelist files. Please see Sucuri's Whitelist File or Folder guide.

iThemes Security plugin

Uncheck "Disable PHP in Plugins" option under "System Tweaks" or "System Modifications"

Defender Security plugin

Make sure you do not "Prevent PHP execution" in your settings.

Defender Plugin > Security Tweaks > Do not "Prevent PHP execution.

Example .htaccess

<Files *.php>
Order allow,deny
Deny from all
</Files>
<Files OneSignalSDKWorker.js.php>
Allow from all
ForceType 'application/javascript; charset=UTF-8'
</Files>
<Files OneSignalSDKWorker.js>
Allow from all
ForceType 'application/javascript; charset=UTF-8'
</Files>

Server slows down or website becomes unreachable upon a notification being sent

This can happen for a few reasons. The below options are ways to help prevent it from occurring. If you continue to see issues, you may need to contact your host provider and upgrade your bandwidth or ask for additional assistance on what is causing this issue.

Don't host your own notification icons

If you are hosting your own images and are using them in your notifications, the your server could be overloaded for requests for that image. This doesn't require users to click the notification as the image must be queried in order to actually display it in the notification.