vercel-community / php

🐘 PHP Runtime for ▲ Vercel Serverless Functions (support 7.4-8.3)
https://php.vercel.app
MIT License
1.21k stars 268 forks source link

PHP Built-In Server HTTP error: Error: connect ECONNREFUSED 127.0.0.1:8000 #541

Open wnsite opened 2 months ago

wnsite commented 2 months ago

Hey, I was testing this package and I set up the example and I got this error: PHP Built-In Server HTTP error: Error: connect ECONNREFUSED 127.0.0.1:8000. The vercel deployed but when I visit the website it shows that error. NOTE: I deployed it all using GitHub and vercel online, I did not install Node.JS or the Vercel CLI on my local machine. Do I need to do that? The site if you want to see for yourself: https://testvercelphp.vercel.app/ My test file structure: vercel.json api/ ├─ index.php

vercel.json: { "functions": { "api/index.php": { "runtime": "vercel-php@0.7.1" } }, "routes": [ { "src": "/(.*)", "dest": "/api/index.php" } ] }

index.php: <?php declare(strict_types = 1);

phpinfo(INFO_ALL & ~INFO_ENVIRONMENT & ~INFO_CONFIGURATION & ~INFO_VARIABLES);

wnsite commented 2 months ago

Fixed! Changed the json to:

{
  "functions": {
    "api/index.php": {
      "runtime": "vercel-php@0.7.1"
    }
  },
  "routes": [
    { "src": "/(.*)", "dest": "/api/index.php" }
  ]
}
qkqpttgf commented 2 months ago

sorry, but where is the different

oijqws commented 2 months ago

got same error but above does not work.

taimaiduc commented 2 months ago

Same error here

vvalentim commented 2 months ago

I was able to deploy the basic examples by setting Node.js version to 18.x on Vercel's project settings, I've tried vercel-php@0.7.1, vercel-php@0.6.2 and vercel-php@0.5.5 with it and it seems fine.

I had the same error PHP Built-In Server HTTP error: Error: connect ECONNREFUSED 127.0.0.1:8000 when using the default version (Node.js 20.x).

taimaiduc commented 2 months ago

The same just want to write comment. Node 18 will work.

f3l1x commented 2 months ago

Hi folks. Node 20.x seems to be problem. I need to investigate it.

joesandiroz2 commented 2 months ago

i get error my web : https://doodplay.vercel.app/ my vercel id : QuBwX4iGVFwYPpmEJApy8H3L

how to fix it

rhtm123 commented 2 months ago

I had the same problem with node 20x. I created package.json file and add this code to use node 18x version.

package.json { "engines": { "node": "18.x" } }

The project is running without any issue

chengfeng30121 commented 2 months ago

I had the same problem. How can I fix it?

YNSTakeru commented 2 months ago

I managed to get it working by changing the Node.js Version in the Settings -> General on Vercel web page.

SrivastavaArjit commented 2 months ago

Did anyone find the solution I am facing the same error.

My file structure is as follows Screenshot 2024-05-16 163147

and my vercel.json file is Screenshot 2024-05-16 163245

I know I haven't defined the routes for all the api's but the index route is also not working.

f3l1x commented 2 months ago

Are you using Node 18.x? Node 20.x is a problem.

SrivastavaArjit commented 2 months ago

Are you using Node 18.x? Node 20.x is a problem.

yeah i have made that change

SrivastavaArjit commented 2 months ago

this solution works! thanks

I had the same problem with node 20x. I created package.json file and add this code to use node 18x version.

package.json { "engines": { "node": "18.x" } }

The project is running without any issue

SrivastavaArjit commented 2 months ago

I know Vercel uses Node.js to build our project and for the creation of Serverless Functions but I didn't quite understand the role of "runtime":"vercel-php@0.7.1"

An explanation would be greatly appreciated. Thank you

imdsamimakhter commented 1 month ago

vercel.json-

{
  "functions": {
    "api/index.php": {
      "runtime": "vercel-php@0.7.1"
    }
  },
  "routes": [
    { "src": "/(.*)", "dest": "/api/index.php" }
  ]
}

package.json- { "engines": { "node": "18.x" } }

Works 👍

zengboin commented 3 weeks ago

The error is:

Spawning: PHP Built-In Server at /var/task/user (document root) and /var/task/user/api/index.php (router)
🐘STDERR: php: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory

Node 20x image has no libssl.so.10

thedoggybrad commented 2 weeks ago

The error is:

Spawning: PHP Built-In Server at /var/task/user (document root) and /var/task/user/api/index.php (router)
🐘STDERR: php: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory

Node 20x image has no libssl.so.10

I have seen that the Node.js 18 will be retired on Vercel next year (Early 2025). By the way, how important is libsssl.so in PHP? (I am just a beginner in PHP) https://vercel.com/docs/functions/runtimes/node-js#node.js-version Screenshot 2024-07-02 130534