Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wnsite opened this issue Apr 22, 2024 · 25 comments
Closed

Comments

@wnsite
Copy link

wnsite commented Apr 22, 2024

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 wnsite closed this as completed Apr 22, 2024
@wnsite wnsite reopened this Apr 22, 2024
@wnsite
Copy link
Author

wnsite commented Apr 22, 2024

Fixed! Changed the json to:

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

@qkqpttgf
Copy link

sorry, but where is the different

@oijqws
Copy link

oijqws commented Apr 23, 2024

got same error but above does not work.

@taimaiduc
Copy link

Same error here

@vvalentim
Copy link

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).

@taimaiduc
Copy link

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

@f3l1x
Copy link
Member

f3l1x commented Apr 26, 2024

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

@joesandiroz2
Copy link

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

how to fix it

@rhtm123
Copy link

rhtm123 commented May 4, 2024

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
Copy link

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

@YNSTakeru
Copy link

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

@SrivastavaArjit
Copy link

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
Copy link
Member

f3l1x commented May 16, 2024

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

@SrivastavaArjit
Copy link

SrivastavaArjit commented May 16, 2024

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

yeah i have made that change

@SrivastavaArjit
Copy link

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
Copy link

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

@imdsamimakhter
Copy link

vercel.json-

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

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

Works 👍

@zengboin
Copy link

zengboin commented Jun 25, 2024

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

@thedoggybrad
Copy link

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

@zengboin
Copy link

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

@sekedus
Copy link

sekedus commented Jul 23, 2024

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

@thedoggybrad
Copy link

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?

@Kenny1291
Copy link

Kenny1291 commented Sep 9, 2024

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

(I made a PR #569)

@Bfaschat
Copy link

Bfaschat commented Sep 27, 2024

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!!!

@f3l1x
Copy link
Member

f3l1x commented Sep 30, 2024

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests