I think part of the problem is that 'localhost' is being interpreted as the IPv6 loopback device ::1 and not the v4 127.0.0.1 - it may be that roundcube has got a wrong mailhost stored. Try running the following SQL command on your roundcube database:
mysql --user=rc -p roundcubemail -e "select username,mail_host from users;"
It will prompt for the password. (Obviously use a different user if it's not 'rc' and a different databasename if it's not 'roundcubemail'
- they are the defaults and are defined in the roundcube config file.)
It will come back with a list of the users defined and the mailhost it will attempt to connect to for that user.
P.
I seem to have forgotten the password I used. Have tried everything. I may have to re-install roundcube.
A bit further up in the roundcube config file there's a line defining the database connection. The username, password and database name are all in the definition - something like
$config['db_dsnw'] = 'mysql://username:password@host/database';
P.