redirect() causing 502 bad gateway errors


I’ve recently moved my yii application to a new server, and although most the tranfser went fine I am getting 502 bad gateway errors on certain redirect() calls.

the simplest example would be in user creation


public function actionCreate(){






This used to work fine on a simple ubuntu server setup for testing but now produces the 502 bad gateway errors on the new server.

The result of this will be the user will be created however I will no longer be able to access any part of the application without 502 bad gateway errors until I clear my browsers cookies.

To further confuse the redirect() call is still working in other areas of the application such as the users corresponding actionDelete() call.

The new server is running Apache/2.2.15 Red Hat, and is green for all the requirements excluding Mcrypt.

Its running Php 5.3.3

I have also ensured the redirect call is using the correct url by hardcoding in the complete url and calling


Thanks in advance for any help or suggestions!

I managed to get create behaviour by replacing the redirect() with :

header('Location: hardcodedurl'.$model->id);

exit; // The exit was needed

the "exit;" line is the only relevant difference between this and the CHttpRequest.redirect() call,

I would still like to use the CController.redirect() method throughout my application, and I know that the issue has arisen due to my being on a new server.

I am wondering if anyone knows of why a server might cause this "exit;" call to be needed?

it’s pretty odd that this is happening.

however, replace your exit call with Yii::app()->end(); otherwise event handlers binded to the onEndRequest event will not be triggered.

Thank you so much for you reply, I had totally neglected to think of the onEndRequest event, and it turns out my error is being caused by the CFileLogRoute.processLogs() event.

By disabling logging my system has returned to normal, and although I still have to puzzle through that error its great that I now know where it is.

maybe the runtime directory is not writable by the webserver ? just guessing …