php / php/php-src

HTTP requests (file_get_contents, curl) times out when calling same server listener

Open
#11,719 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description
Issue

When a script makes a HTTP call on Windows to the same host/server listener - it will time out.

Steps to reproduce:
  1. Install PHP 8.2.8 for Windows
  2. Create bug/test.php file with following code:
<?php
echo $_GET['say'] ?? file_get_contents('http://localhost/test.php?say=hello');
  1. cd bug and start a php server in that folder: php -S localhost:80
  2. Try to run the script, it will time out: php test.php

The script will time out, as the file_get_contents never responds.

Expected result

It should echo hello to the console

Further testing

This issue extends further than file_get_contents and php web server - it also affects:

  • curl functions curl_exec etc not just file_get_contents
  • Using php-cgi.exe and nginx on Windows with fastcgi_pass
  • Also tested with Caddy web server, using proxy pass, same issue
Linux/Unix

This doesn't affect linux. Trying the above reproduction steps in Linux will echo hello. It also works as expected when using WSL/Windows Sub System for Linux.

PHP Version

PHP 8.2.8

Operating System

Windows 10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Windows reproduction in bug/test.php and compare file_get_contents('http://localhost/test.php?say=hello') with the documented curl_exec cases. Reproduce using PHP 8.2.8 and php -S localhost:80 on Windows, then verify that the request completes and echoes hello without regressing the Linux/WSL behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.