php icon indicating copy to clipboard operation
php copied to clipboard

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

Open wnsite opened this issue 1 year ago • 22 comments

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": "[email protected]" } }, "routes": [ { "src": "/(.*)", "dest": "/api/index.php" } ] }

index.php:

wnsite avatar Apr 22 '24 20:04 wnsite

Fixed! Changed the json to:

{
  "functions": {
    "api/index.php": {
      "runtime": "[email protected]"
    }
  },
  "routes": [
    { "src": "/(.*)", "dest": "/api/index.php" }
  ]
}

wnsite avatar Apr 22 '24 21:04 wnsite

sorry, but where is the different

qkqpttgf avatar Apr 23 '24 13:04 qkqpttgf

got same error but above does not work.

oijqws avatar Apr 23 '24 13:04 oijqws

Same error here

taimaiduc avatar Apr 26 '24 14:04 taimaiduc

I was able to deploy the basic examples by setting Node.js version to 18.x on Vercel's project settings, I've tried [email protected], [email protected] and [email protected] 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).

vvalentim avatar Apr 26 '24 16:04 vvalentim

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

taimaiduc avatar Apr 26 '24 17:04 taimaiduc

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

f3l1x avatar Apr 26 '24 17:04 f3l1x

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

how to fix it

joesandiroz2 avatar Apr 28 '24 09:04 joesandiroz2

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

rhtm123 avatar May 04 '24 07:05 rhtm123

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

chengfeng30121 avatar May 08 '24 10:05 chengfeng30121

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

YNSTakeru avatar May 09 '24 20:05 YNSTakeru

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.

SrivastavaArjit avatar May 16 '24 11:05 SrivastavaArjit

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

f3l1x avatar May 16 '24 11:05 f3l1x

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

yeah i have made that change

SrivastavaArjit avatar May 16 '24 11:05 SrivastavaArjit

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 avatar May 16 '24 11:05 SrivastavaArjit

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":"[email protected]"

An explanation would be greatly appreciated. Thank you

SrivastavaArjit avatar May 16 '24 11:05 SrivastavaArjit

vercel.json-

{
  "functions": {
    "api/index.php": {
      "runtime": "[email protected]"
    }
  },
  "routes": [
    { "src": "/(.*)", "dest": "/api/index.php" }
  ]
}

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

Works 👍

imdsamimakhter avatar May 21 '24 17:05 imdsamimakhter

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 20.x image has no libssl.so.10

zengboin avatar Jun 25 '24 04:06 zengboin

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

thedoggybrad avatar Jul 02 '24 05:07 thedoggybrad

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

PHP use libssl.so in curl extension and openssl extension. using curl to request the https website

zengboin avatar Jul 18 '24 01:07 zengboin

This solution worked for me:

{
  "functions": {
    "api/index.php": {
      "runtime": "[email protected]"
    }
  },
  "rewrites": [
    { "source": "/(.*)", "destination": "/api/index.php" }
  ]
}

And change node.js version to 18.x : #504

sekedus avatar Jul 23 '24 11:07 sekedus

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

PHP use libssl.so in curl extension and openssl extension. using curl to request the https website

So with no libssl.so, basically CURL will be dead right?

thedoggybrad avatar Jul 24 '24 09:07 thedoggybrad

Why is not specified in the readme that Node 18.x must be selected?

(I made a PR #569)

Kenny1291 avatar Sep 09 '24 11:09 Kenny1291

For anyone still faced with this issue, do the following

Step 1: Use a working example

PHP - fast & simple

Step 2: replace the api/index.php file content with this

<?php
phpinfo();

Step 3: Switch from Node 20.x to Node 18.x under vercel settings

image

Step 4: Redeploy your project and Voila!!!

image

Enjoy!!!

Bfaschat avatar Sep 27 '24 23:09 Bfaschat

Hey all! It should be fixed to use Node 20.x, can you folks try version 0.7.2 with Node 20.x?

https://example-php-8-3.vercel.app/

f3l1x avatar Sep 30 '24 09:09 f3l1x