Title: When switching 502 Error
Last modified: August 31, 2016

---

# When switching 502 Error

 *  Resolved [EvgenBest](https://wordpress.org/support/users/evgen81/)
 * (@evgen81)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/when-switching-502-error-1/)
 * wp-login.php?action=switch_to_user&user_id=44&_wpnonce=328eeae39d&redirect_to
   =http%3A%2F%2Fmirtraderov.ru%2Fmembers%2Ftim-rod%2F
 * wp-login.php?action=switch_to_user&user_id=38&_wpnonce=89b65a8ca8&redirect_to
   =http%3A%2F%2Fmirtraderov.ru%2Fmembers%2Fpropunion%2F
 * wp-login.php?action=switch_to_user&user_id=45&_wpnonce=0245b0885f&redirect_to
   =http%3A%2F%2Fmirtraderov.ru%2Fmembers%2Ftraderspb%2F
 * [https://wordpress.org/plugins/user-switching/](https://wordpress.org/plugins/user-switching/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [10 years, 5 months ago](https://wordpress.org/support/topic/when-switching-502-error-1/#post-7288184)
 * * Can you take a look in your server logs for the actual error message?
    * Does
   it happen every single time you try to switch or only sometimes? * Can you restart
   Nginx/Apache and PHP and see if the problem persists?
 * This is almost certainly not a problem with User Switching, just that a problem
   or misconfiguration on your server is manifesting itself when switching users.
 *  [CodeMonkeyBanana](https://wordpress.org/support/users/codemonkeybanana/)
 * (@codemonkeybanana)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/when-switching-502-error-1/#post-7288310)
 * I am getting the same problem. It is down to the try_files rule but I don’t know
   how to fix it.
 * This is my try_files
 *     ```
       location / {
           try_files $cachefile $uri $uri/ /index.php$is_args$args;
       }
       ```
   
 * This is the common setup used. I think problem is that it only routes GET parameters
   to index.php.
 * It needs to be modified to allow for other pages also, I am not an nginx expert
   though so hopefully someone can lend a hand here.
 *  [CodeMonkeyBanana](https://wordpress.org/support/users/codemonkeybanana/)
 * (@codemonkeybanana)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/when-switching-502-error-1/#post-7288311)
 * Actually I just noticed several other plugins have URLS with query parameter 
   that don’t involve index.php and they work fine.
 * Also this works fine:
 * `https://example.com/wp-login.php?action=switch_to_user&user_id=16&_wpnonce=123`
 * However, this gives 502:
 * `https://subdomain.example.com/wp-login.php?action=switch_to_user&user_id=16&
   _wpnonce=123`
 * I think there must be something more to why this isn’t working.
 *  [CodeMonkeyBanana](https://wordpress.org/support/users/codemonkeybanana/)
 * (@codemonkeybanana)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/when-switching-502-error-1/#post-7288312)
 * I looked in nginx log and saw there was an error:
 * `*1 upstream sent too big header while reading response header from upstream`
 * Seems the header is larger than nginx default buffer size.
 * Setting this will fix it:
 * `fastcgi_buffer_size 32k;`
 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [10 years, 5 months ago](https://wordpress.org/support/topic/when-switching-502-error-1/#post-7288314)
 * [@codemonkeybanana](https://wordpress.org/support/users/codemonkeybanana/) Thanks
   so much for the follow-up!
 * Can you check your cookies (in your browser console) for the domain in question
   please?
 * I suspect there will be a whole bunch of cookies in there (maybe old WordPress
   ones), and switching user just happens to push this over the default buffer size
   in nginx (switching user sets two extra cookies on top of WordPress’ own cookies).
 *  [CodeMonkeyBanana](https://wordpress.org/support/users/codemonkeybanana/)
 * (@codemonkeybanana)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/when-switching-502-error-1/#post-7288323)
 * `document.cookie.length == 185`
 * Not sure if that’s what you mean?
 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [10 years, 5 months ago](https://wordpress.org/support/topic/when-switching-502-error-1/#post-7288327)
 * Well that’s nothing out of the ordinary, so I’m not sure of the actual problem.
   Maybe your site sends a bunch of headers.
 * I think the default buffer size in Nginx is 8k so that’s not that hard to fill
   up.
 *  [CodeMonkeyBanana](https://wordpress.org/support/users/codemonkeybanana/)
 * (@codemonkeybanana)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/when-switching-502-error-1/#post-7288328)
 * Yeah, I have a debug header in there that outputs a few env vars. That might 
   have tipped it over the edge.

Viewing 8 replies - 1 through 8 (of 8 total)

 The topic ‘When switching 502 Error’ is closed to new replies.

 * ![](https://ps.w.org/user-switching/assets/icon.svg?rev=3193956)
 * [User Switching](https://wordpress.org/plugins/user-switching/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-switching/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-switching/)
 * [Active Topics](https://wordpress.org/support/plugin/user-switching/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-switching/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-switching/reviews/)

 * 8 replies
 * 3 participants
 * Last reply from: [CodeMonkeyBanana](https://wordpress.org/support/users/codemonkeybanana/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/when-switching-502-error-1/#post-7288328)
 * Status: resolved