use 127.0.0.1 instead of localhost for db host parameter

localhost means connect via socket, which is in some cases not available
or wrong configured or differs from the place php assumes it.

known Downsides: there may be performance impacts, but I never had something noticeable

Reason: It happens regularly that people have connection problems with localhost, which nearly always got resolved by changing to 127.0.0.1