# An Internal Server Error Occurred

**URL:** <https://discourse.cakephp.org/t/an-internal-server-error-occurred/3908>\
**Category:** Need Help\
**Created:** [February 11, 2018, 11:54am UTC](https://discourse.cakephp.org/t/an-internal-server-error-occurred/3908 "2018-02-11T11:54:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ole](https://avatars.discourse-cdn.com/v4/letter/o/fbc32d/32.png) [@ole](https://discourse.cakephp.org/u/ole)\
**Post date:** [February 11, 2018, 11:54am UTC](https://discourse.cakephp.org/t/an-internal-server-error-occurred/3908/1 "2018-02-11T11:54:41Z")

</div>

Hello,

since i inserted  
"function beforeRender(Event $event){  
$this-\>set(‘authuser1’, $this-\>Auth-\>user());  
}"  
into AppController my Error Debug does’nt work… I get this:

An Internal Server Error Occurred

only…

If i commented this, it works.

Can someone help me?

THX  
Ole

---

<div class="post-metadata">

**Author:** ![raul338](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/raul338/32/69_2.png) [@raul338](https://discourse.cakephp.org/u/raul338)\
**Post date:** [February 11, 2018, 12:48pm UTC](https://discourse.cakephp.org/t/an-internal-server-error-occurred/3908/2 "2018-02-11T12:48:08Z")

</div>

Do you have an error controller? Does it extends AppController?

AFAIK Error controller does not load any component by default (including Auth) so you try to access Auth in beforeRender and is not loaded, php throws a “Cant get property user of null” exception

You might want to load AuthComponent in you ErrorController or add an if to check if Auth is loaded (or a try?)

---

<div class="post-metadata">

**Author:** ![dmuenstermann](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@dmuenstermann](https://discourse.cakephp.org/u/dmuenstermann)\
**Post date:** [February 12, 2018, 2:17pm UTC](https://discourse.cakephp.org/t/an-internal-server-error-occurred/3908/3 "2018-02-12T14:17:25Z")

</div>

Do you have a

> use Cake\Event\Event;

at the beginning of your class-file?

---

<div class="post-metadata">

**Author:** ![ole](https://avatars.discourse-cdn.com/v4/letter/o/fbc32d/32.png) [@ole](https://discourse.cakephp.org/u/ole)\
**Post date:** [February 13, 2018, 9:25pm UTC](https://discourse.cakephp.org/t/an-internal-server-error-occurred/3908/4 "2018-02-13T21:25:42Z")

</div>

hi,

thanks for helping.

I have to load Auth-Component into my AppController. Now it works fine!

Ole

---

<div class="post-metadata">

**Author:** ![ammukarthi](https://avatars.discourse-cdn.com/v4/letter/a/90db22/32.png) [@ammukarthi](https://discourse.cakephp.org/u/ammukarthi)\
**Post date:** [September 16, 2019, 5:12am UTC](https://discourse.cakephp.org/t/an-internal-server-error-occurred/3908/5 "2019-09-16T05:12:09Z")

</div>

i have loaded auth component still it does not work

---

<div class="post-metadata">

**Author:** ![karmicdice](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/karmicdice/32/1298_2.png) [@karmicdice](https://discourse.cakephp.org/u/karmicdice)\
**Post date:** [September 16, 2019, 5:59am UTC](https://discourse.cakephp.org/t/an-internal-server-error-occurred/3908/6 "2019-09-16T05:59:54Z")

</div>

Please start a different thread and show code for the community to look at.
