Skip to main content

Using ngrok with Wordpress


This article assumes you familiar with moderate to advanced Wordpress configuration.

To make ngrok work properly with Wordpress installations you usually need to do these three things:

  1. You must instruct ngrok to rewrite the host header and point to the port of your Wordpress install (usually port 80), like so:

    ngrok http 80 --host-header=rewrite --domain
  2. You must ensure that Wordpress understands that it is meant to serve itself from your tunneled hostname. You can configure Wordpress to do that by modifying your wp-config to include the following lines where is replaced with the URL from ngrok:

        define('.COOKIE_DOMAIN.', '');
    define('.SITECOOKIEPATH.', '.');

    if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
    $_SERVER['REMOTE_ADDR'] = $list[0];
    define( 'WP_HOME', '' );
    define( 'WP_SITEURL', '' );
    $_SERVER['HTTP_HOST'] = '';
    $_SERVER['REMOTE_ADDR'] = '';
    $_SERVER[ 'SERVER_ADDR' ] = '';