patrik
Verified User
- Joined
- Sep 6, 2006
- Messages
- 128
I'm experiencing this really strange problem which has something to do with hostname lookups in PHP. When Apache has been running for some time hostname lookups tends to stop working.
This is the error message given from a site:
When this occurs it is possible to refresh the site and sometimes it works but mostly it doesn't. A restart of apache fixes the problem temporarily. It's also possible to fix this permanent by adding mysql_hostname to /etc/hosts Please help me figure out why this occurs. This have happend on two different servers (running PHP5 and PHP4 and both using an external dedicated MySQL server). I have also tried changing nameservers in /etc/resolv.conf but it didn't help.
This is the error message given from a site:
Code:
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host '[b]mysql_hostname[/b]' (2) in /path/to/script.php on line 71
Warning: mysql_select_db() [function.mysql-select-db]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /path/to/script.php on line 72
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /path/to/script.php on line 72
When this occurs it is possible to refresh the site and sometimes it works but mostly it doesn't. A restart of apache fixes the problem temporarily. It's also possible to fix this permanent by adding mysql_hostname to /etc/hosts Please help me figure out why this occurs. This have happend on two different servers (running PHP5 and PHP4 and both using an external dedicated MySQL server). I have also tried changing nameservers in /etc/resolv.conf but it didn't help.