# mysql_connect('localhost') should use tcp/ip instead of socket

- Thread: https://externals.io/message/13110
- Original archive: https://news-web.php.net/php.internals/13110
- Started by Roland Tapken on 2004-10-03T00:39:13+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #13110 — Roland Tapken — 2004-10-03T00:39:13+00:00

URL: https://externals.io/message/13110#13110

Hi!

When using 'localhost' in mysql_connect(), php tries to use a socket
to connect to the mysql daemon. Is there a way to force php to resolve
the hostname of localhost, maybe by patching some source file? The
reason is that a socket is not avaible because mysql and apache are
running in different chroot jails on my server.

gruß, Roland
-- 
"Ich kenne niemanden, der nachts vom
 Kiffen nach Hause kommt und seine Frau schlägt."

---

## #13111 — Sara Golemon — 2004-10-03T01:26:57+00:00

URL: https://externals.io/message/13110#13111 · In reply to: #13110

> When using 'localhost' in mysql_connect(), php tries to
> use a socket to connect to the mysql daemon. Is there
> a way to force php to resolve the hostname of localhost,
> maybe by patching some source file? The reason is that
> a socket is not avaible because mysql and apache are
> running in different chroot jails on my server.
>
Actually that's libmysql doing that, not PHP.  The way around that 
"shortcut" is to connect to 127.0.0.1 (by ip) rather than localhost (by 
name) which of course you can handle in your script code without having to 
patch PHP or libmysql directly.

-Sara
