Phpstorm Xdebug Error: cannot Accept External Xdebug Connection: Cannot Evaluate Expression '$_server['server_port']'

Recently while trying to set up XDebug and PHPStorm for remote debugging I came accross the following error:

cannot Accept External Xdebug Connection: Cannot Evaluate Expression '$_server['server_port']'

I managed to fix this error by adding the following to my nginx.conf:

fastcgi_param    SERVER_PORT    $server_port;

Tags: phpstormxdebugnginx