localhost request fails with PHP built-in webserver
iharsuvorau opened this issue · comments
I'm not sure it's the issue with drakma
, because dexador
, for example, fails in the same way. So, please, maybe you can point to where should I look to solve the issue. The long version is on the stackoverflow still open question.
Seems like the problem is related to the particular PHP built-it webserver for development, because the issue is reproducible only with:
- the PHP webserver (version is specified below)
- SBCL (
sbcl/1.4.16
) - Drakma (
2.0.4
) - and serving from localhost
But the PHP webserver serves fine for curl
, a Go client, a web browser.
PHP version:
PHP 7.3.1 (cli) (built: Jan 10 2019 13:16:34) ( NTS ) Copyright (c)
1997-2018 The PHP Group Zend Engine v3.3.1, Copyright (c) 1998-2018
Zend Technologies
with Zend OPcache v7.3.1, Copyright (c) 1999-2018, by Zend Technologies
-- installed with brew install php
.
Steps to reproduce
The server:
php -S localhost:7070
Then try with clients:
curl "http://localhost:7070"
-- works fine (status code 404 is expected and received).
Lisp:
(drakma:http-request "http://localhost:7070")
-- fails (status code 404 is expected but connection refused
is returned).
Is localhost correctly resolving? There is no ipv4-ipv6 discrepancies?
Is localhost correctly resolving?
I request the localhost with curl
successfully, seems like it resolves correctly, doesn't it?
dig localhost
→ 127.0.0.1
There is no ipv4-ipv6 discrepancies?
How do I check this? Still, it works fine for web browsers, curl
and Go-programs at least.
Does (drakma:http-request "http://127.0.0.1:7070") work?
Does (drakma:http-request "http://127.0.0.1:7070") work?
Nope. The same USOCKET:CONNECTION-REFUSED-ERROR
error.
And curl http://127.0.0.1:7070 ?
And curl http://127.0.0.1:7070 ?
Well, curl
also fails with Connection refused
using 127.0.0.1:7070
, but works with localhost:7070
. Why is that?
netstat -n | grep 7070
Rather do lsof -n -i:7070
lsof -n -i:7070
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php 96090 ihar 7u IPv6 0x7ad446e2d88a5083 0t0 TCP [::1]:arcp (LISTEN)
So, it's listening on an ipv6 address indeed. I guess start it with php -S 127.0.0.1:7070
So, it's listening on an ipv6 address indeed. I guess start it with php -S 127.0.0.1:7070
You're correct. That works.
Thanks a lot for your time explaining that to me.