PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 25, 2022

[FIXED] CakePHP Connection Refused in Browser

 January 25, 2022     apache, cakephp, cakephp-3.0, php, ubuntu-server     No comments   

Issue

I'm working on setting up/learning CakePHP for the first time and I am struggling to figure out why I cannot reach my server over the default port 8765. I like to develop on an ubuntu machine and work on the code remotely. The server is hosted on a vm on my local machine, but i am referring to it as the remote machine. Both the server and my remote machine are on the same 10.0.1.x subnet. I can reach the server over port 80 fine. However, when I attempt to reach hxxp://10.0.1.44:8765/ I get the following message

Failed to connect to 10.0.1.44 port 8765: Connection refused

I've tried disabling my firewall on the Ubuntu 16 server by doing sudo uff disable and that didn't work. I've also tried editing my Apache2.conf file and overriding the directory permissions. These are my current global permissions:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

Any help is greatly appreciated!


Solution

develop on an ubuntu machine and work on the code remotely

The problem you likely have is that php's built-in web server (which CakePHP's server shell uses) does not bind to all ip addresses - it only binds to the ip and host name you start it on.

To have the server listen to all ip addresses and respond however it's accessed, use '0.0.0.0' as the hostname:

-> bin/cake server -H 0.0.0.0

Welcome to CakePHP v3.1.3 Console
---------------------------------------------------------------
App : src
Path: /var/www/cakephp.dev/src/
DocumentRoot: /var/www/cakephp.dev/webroot
---------------------------------------------------------------
built-in server is running in http://0.0.0.0:8765/
You can exit with `CTRL-C`

Note that if you're using the development server - apache config is irrelevant as apache is playing no role in serving requests.



Answered By - AD7six
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing