# Nextcloud internal server error [MySQL issue] [Solved]

## tabanus

I had Nextcloud working perfectly with lighttpd and mysql, but after a re-boot it's started to refuse connections.

The web interface says "Internal Server Error".

In the /var/log/lighttpd/error.log I'm getting lots of errors that look like this:

```
2018-01-22 22:45:40: (mod_fastcgi.c.2543) FastCGI-stderr: PHP message: {"reqId":"uzUA4itXhxCCbIjFIK4a","level":3,"time":"2018-01-22T22:45:40+00:00","remoteAddr":"x.x.x.x",

"user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/status.php","message":"touch(): Utime failed: Permission denied at \/var\/www\/localhost\/htdocs\/nextcloud\/lib\/private\/Config.php#239","userAgent":"Mozilla\/5.0 (Linux) mirall\/2.3.3 (Nextcloud)","version":""}

2018-01-22 22:45:40: (mod_fastcgi.c.2543) FastCGI-stderr: PHP message: {"reqId":"uzUA4itXhxCCbIjFIK4a","level":3,"time":"2018-01-22T22:45:40+00:00","remoteAddr":"x.x.x.x",

"user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/status.php","message":"fopen(\/var\/www\/localhost\/htdocs\/nextcloud\/config\/config.php): failed to open stream: Permission denied at \/var\/www\/localhost\/htdocs\/nextcloud\/lib\/private\/Config.php#240","userAgent":"Mozilla\/5.0 (Linux) mirall\/2.3.3 (Nextcloud)","version":""}

2018-01-22 22:45:40: (mod_fastcgi.c.2543) FastCGI-stderr: PHP message: {"reqId":"uzUA4itXhxCCbIjFIK4a","level":3,"time":"2018-01-22T22:45:40+00:00","remoteAddr":"x.x.x.x",

"user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/status.php","message":"chmod(): Operation not permitted at \/var\/www\/localhost\/htdocs\/nextcloud\/lib\/private\/Config.php#243","userAgent":"Mozilla\/5.0 (Linux) mirall\/2.3.3 (Nextcloud)","version":""}

2018-01-22 22:45:40: (mod_fastcgi.c.2543) FastCGI-stderr: PHP message: {"reqId":"uzUA4itXhxCCbIjFIK4a","level":4,"time":"2018-01-22T22:45:40+00:00","remoteAddr":"x.x.x.x",

"user":"--","app":"remote","method":"GET","url":"\/nextcloud\/status.php","message":"Can't write into config directory!","userAgent":"Mozilla\/5.0 (Linux) mirall\/2.3.3 (Nextcloud)","version":""}

2018-01-22 22:45:40: (mod_fastcgi.c.2543) FastCGI-stderr: PHP message: {"reqId":"uzUA4itXhxCCbIjFIK4a","level":3,"time":"2018-01-22T22:45:40+00:00","remoteAddr":"x.x.x.x",

"user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/status.php","message":"fopen(\/var\/www\/localhost\/htdocs\/nextcloud\/data\/nextcloud.log): failed to open stream: Permission denied at \/var\/www\/localhost\/htdocs\/nextcloud\/lib\/private\/Log\/File.php#132","userAgent":"Mozilla\/5.0 (Linux) mirall\/2.3.3 (Nextcloud)","version":""}

```

(I've replaced the ip address with x.x.x.x . This address is the IP of a client trying to connect in).

Maybe a permissions thing, or have I screwed up the connection to mysql somehow?

[Moderator edit: broke long whitespace-free lines in code tags to fix thread layout. -Hu]Last edited by tabanus on Wed Jan 24, 2018 12:05 pm; edited 2 times in total

----------

## toofied

 *tabanus wrote:*   

> I had Nextcloud working perfectly with lighttpd and mysql, but after a re-boot it's started to refuse connections. 
> 
> The web interface says "Internal Server Error".

 

Permission errors, probably occurred after an update. 

Relevant threads:

https://help.nextcloud.com/t/nc-12-stuck-in-upgrade-mode/18863

https://help.nextcloud.com/t/error-updating-to-11-0-3/11769

----------

## tabanus

This is a new installation. Was fine until I re-booted.

----------

## tabanus

I've isolated the problem to my mysql setup.

Found this in the Nextcloud log:

```
An exception occurred while executing 'DELETE FROM `oc_authtoken` WHERE `token` = ?' with params ["db1250623b74e1394098e5c8e1add8d2b2d1d27f0158ea9d75e3068dd6e1c76849723a49b337efa040abc4e4d37262088f82e3c38fe678f061b39c2d982a49ee"]: SQLSTATE[HY000]: General error: 1665 Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
```

I sorted this by logging into mysql and setting the binary log format to ROW, and everything works again.

I know I did this when I set up in the first place, so the question now is: how do I make this persist after a reboot?

The mysql website says 

 *Quote:*   

> You can select the binary logging format explicitly by starting the MySQL server with --binlog-format=type.

 

I can't see anything in the mysql config files to set this though.

----------

## tabanus

Finally sorted. For anyone else hitting this problem, solved by adding this line to the [mysqld] section of /etc/mysql/my.cnf

```
binlog-format                   = ROW
```

Thanks for your help everyone.   :Wink: 

----------

