{"id":5838,"date":"2026-02-06T11:37:02","date_gmt":"2026-02-06T16:37:02","guid":{"rendered":"https:\/\/specialmansolution.com\/en-us\/uncategorized\/how-to-fix-502-bad-gateway-error-in-cwp-user-panel-after-domain-migration\/"},"modified":"2026-02-06T11:37:05","modified_gmt":"2026-02-06T16:37:05","slug":"how-to-fix-502-bad-gateway-error-in-cwp-user-panel-after-domain-migration","status":"publish","type":"post","link":"https:\/\/specialmansolution.com\/en-us\/nerd-blog\/how-to-fix-502-bad-gateway-error-in-cwp-user-panel-after-domain-migration\/","title":{"rendered":"How to Fix 502 Bad Gateway Error in CWP User Panel After Domain Migration"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Problem Overview<\/h2>\n\n\n\n<p>When you migrate a domain from one server to another but leave the original user account intact on the old CWP (CentOS Web Panel) server, you may encounter a <strong>502 Bad Gateway<\/strong> error with &#8220;cwpsrv&#8221; displayed when trying to access that user&#8217;s control panel.<\/p>\n\n\n\n<p>This occurs because the cwpsrv (CWP&#8217;s web server) configuration still references the old domain&#8217;s proxy settings and backend services that no longer exist on the server. The configuration expects certain services or resources to be available for the domain, but since the domain has been moved, those references become broken, resulting in the 502 error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding the Issue<\/h2>\n\n\n\n<p>CWP uses <strong>cwpsrv<\/strong> as its internal web server to handle user panel requests. When a domain is properly hosted on the server, cwpsrv has the correct configuration to proxy requests to the appropriate backend services. However, when you:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Move a domain to another server<\/li>\n\n\n\n<li>Leave the user account on the old server<\/li>\n\n\n\n<li>Don&#8217;t update the cwpsrv configuration<\/li>\n<\/ol>\n\n\n\n<p>The result is a mismatch between what cwpsrv expects and what actually exists, causing the gateway error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Solution<\/h2>\n\n\n\n<p>The fix is straightforward: rebuild the cwpsrv configuration for the affected user account. This regenerates the configuration files with the current state of the user&#8217;s domains and services.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step-by-Step Fix<\/h3>\n\n\n\n<p><strong>Step 1: Rebuild the user&#8217;s cwpsrv configuration<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/local\/cwpsrv\/htdocs\/resources\/scripts\/cwpsrv_rebuild_user_conf username\n<\/code><\/pre>\n\n\n\n<p>Replace <code>username<\/code> with the actual CWP username experiencing the issue.<\/p>\n\n\n\n<p><strong>Step 2: Restart the cwpsrv service<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart cwpsrv\n<\/code><\/pre>\n\n\n\n<p><strong>Step 3: Test access<\/strong><\/p>\n\n\n\n<p>Try logging into the user panel again. The 502 error should now be resolved.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Alternative Solutions<\/h2>\n\n\n\n<p>If rebuilding the configuration doesn&#8217;t work, here are additional troubleshooting steps:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Check cwpsrv Status<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status cwpsrv\n<\/code><\/pre>\n\n\n\n<p>Ensure the service is running properly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Review User Configuration<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/usr\/local\/cwpsrv\/conf.d\/users\/username.conf\n<\/code><\/pre>\n\n\n\n<p>This lets you see what configuration exists for the user and identify any problematic entries.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Check cwpsrv Logs<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>tail -f \/usr\/local\/cwpsrv\/logs\/error_log\n<\/code><\/pre>\n\n\n\n<p>Review the logs while attempting to access the user panel to see specific error messages.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Temporarily Disable User Configuration<\/h3>\n\n\n\n<p>If you need immediate access and the rebuild doesn&#8217;t work:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mv \/usr\/local\/cwpsrv\/conf.d\/users\/username.conf \/usr\/local\/cwpsrv\/conf.d\/users\/username.conf.bak\nsystemctl restart cwpsrv\n<\/code><\/pre>\n\n\n\n<p>This temporarily removes the problematic configuration. You can restore it later or regenerate it properly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prevention<\/h2>\n\n\n\n<p>To avoid this issue in the future:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Remove domains properly<\/strong> before migration using CWP&#8217;s domain management interface<\/li>\n\n\n\n<li><strong>Delete user accounts<\/strong> if they&#8217;re no longer needed after migration<\/li>\n\n\n\n<li><strong>Rebuild configurations<\/strong> after any major changes to user accounts or domains<\/li>\n\n\n\n<li><strong>Use CWP&#8217;s migration tools<\/strong> when available to ensure proper cleanup<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">When to Delete the User Account<\/h2>\n\n\n\n<p>If the user account is no longer needed on the old server (all domains have been migrated), consider removing it entirely:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># From CWP root panel: User Accounts \u2192 List Accounts \u2192 Delete\n<\/code><\/pre>\n\n\n\n<p>Or check available removal scripts:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -la \/scripts\/ | grep remove\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The 502 Bad Gateway error in CWP user panels after domain migration is a configuration mismatch issue that&#8217;s easily resolved by rebuilding the cwpsrv configuration for the affected user. The <code>cwpsrv_rebuild_user_conf<\/code> script regenerates the proper configuration based on the current state of the server, eliminating references to migrated or removed domains.<\/p>\n\n\n\n<p>This is a common scenario in server administration when domains are moved between servers, and knowing the quick fix can save significant troubleshooting time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem Overview When you migrate a domain from one server to another but leave the original user account intact on the old CWP (CentOS Web Panel) server, you may encounter a 502 Bad Gateway error with &#8220;cwpsrv&#8221; displayed when trying to access that user&#8217;s control panel. This occurs because the cwpsrv (CWP&#8217;s web server) configuration [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5839,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11],"tags":[25],"class_list":["post-5838","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nerd-blog","tag-cwp"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/specialmansolution.com\/en-us\/wp-json\/wp\/v2\/posts\/5838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/specialmansolution.com\/en-us\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/specialmansolution.com\/en-us\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/specialmansolution.com\/en-us\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/specialmansolution.com\/en-us\/wp-json\/wp\/v2\/comments?post=5838"}],"version-history":[{"count":0,"href":"https:\/\/specialmansolution.com\/en-us\/wp-json\/wp\/v2\/posts\/5838\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/specialmansolution.com\/en-us\/wp-json\/wp\/v2\/media\/5839"}],"wp:attachment":[{"href":"https:\/\/specialmansolution.com\/en-us\/wp-json\/wp\/v2\/media?parent=5838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/specialmansolution.com\/en-us\/wp-json\/wp\/v2\/categories?post=5838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/specialmansolution.com\/en-us\/wp-json\/wp\/v2\/tags?post=5838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}