gwomacks / php-debug

Atom Text Editor package for PHP debugging
MIT License
119 stars 31 forks source link

Could not bind socket #240

Closed kenorb closed 6 years ago

kenorb commented 7 years ago

I've the following error since upgrade to v0.2.5:

Could not bind socket, do you already have an instance of the debugger open?

I've tried to restart Apache and Atom editor, and I've only one instance of the editor. I'm not sure how to debug this. My configuration is as per #236

cchamplin commented 7 years ago

There were adjustments made on 0.2.5 that changed how PHP-Debug bound to local addresses. Is it possible that atom might not be able to bind to the default address of 127.0.0.1?

peterolivo commented 7 years ago

I am having this same issue. I have not changed my development box or the config away from the defaults. What changes were made and can you reference them?

Kelthan commented 7 years ago

Same issue here.

To reproduce: change Server Address to * close Atom open Atom try to open PHP Debug view

Work around: change Server Address to default (127.0.0.1) close Atom open Atom change Server Address to * open PHP Debug view

rohitsodhia commented 7 years ago

I'm also facing the same issue, but the workaround by @Kelthan seems to work for me. As it's my first time using the plugin, I'm not positive, but I'm not getting the connection error anymore.

However, if I close the debug pane after it makes the connection and try to reopen it, the error comes back and I have to redo the process (set to 127, restart, etc). Changing the values directly in the settings cson doesn't seem to work.

Small update: though it says it's listening on the correct ip/port, breakpoints don't seem to actually hold the code, so it's possible I'm doing something wrong as well...

rohitsodhia commented 7 years ago

An update from my end, if I try the workaround mentioned by @Kelthan, changing the IP doesn't get the app listening on the new IP; running a netstat -a -b shows atom is still listening on 127.0.01. Restarting the app from there gives back the original error.

stevenng308 commented 7 years ago

I am also experiencing this issue.

When I close and open atom php-debug cannot bind to socket. I have to set the ip address in the setting to the default value, uninstall the plugin, reinstall the plugin and enter the correct ip address again in order to get around the issue.

EDIT

Reinstalling the plugin is not necessary. Just changing the IP and port then restarting Atom and apply the custom IP and port again gets around this issue.

Any updates on this issue? Thanks!

fede-green commented 6 years ago

Having the same issue, sadly :(. Works if i change the address to default, but that is not the one i need for xdebug to work as everything i have is on vagrant boxes.

hope there will be a solution at some point, i don't want to switch to another IDE :)

EvKoh commented 6 years ago

I am having this same issue :(

tillkolter commented 6 years ago

I am just getting started with php development and Atom so apologies, if my answer is not helping all of you, but maybe it is. I found this bug googling as I was facing the same problem on Mac (no VM)

With the developer console open (View > Developer > Toggle Developer Tools) I could find the actual problem, which was that the address was already in use.

screen shot 2017-10-06 at 23 35 25

With lsof -i tcp:9000 on the command line I could find that the FastCGI Process Manager for PHP was listening to the port. I killed it by running brew services stop php71 and now the debugger works just fine.

I am new to PHP so I dont know if I solved the problem at the wrong end. Hope this helps anybody.

way5 commented 6 years ago

I did the following to fix this: php.ini: xdebug.remote_port=9001 then, Atom config:

"php-debug":
    ServerPort: 9001
    …

Restart PHP and Atom. Now it works for me. I should mention also the plugin has some "bugs", so don't be surprised if it suddenly will show you "Socket is busy" message. Just restart Atom in that case. Cheers

guaneagler commented 6 years ago

Config is ok, but is still has issue "Could not bind socket, do you already have an instance of the debugger open?". Finally I change it to 0.2.4 with this command "apm install php-debug@0.2.4". Hoping 0.2.5 will be ok sooner.

cchamplin commented 6 years ago

Alright so I believe this is likely caused by the changes to the server binding for the plugin in 0.2.5. I've fixed several issues around this in 0.2.6.

You may still experience problems because xdebug is attempting to connect to a different address then the new default (127.0.0.1). You can have PHP-Debug bind to all addresses (0.0.0.0) [The behavior in 0.2.4 and below] by setting the ServerAddress option to "*"

Please let me know if this resolves the issue for you

jaylong255 commented 6 years ago

what a rabbit hole!!! so i pieced together a solution out of everything that was said here because no one fix here did it for me exactly. so here's what i did if it helps anybody.

my setup:

in xdebug: vagrant ssh in these files:

add this: zend_extension=xdebug.so xdebug.remote_enable=1 xdebug.remote_connect_back = 1 xdebug.remote_port = 9999 xdebug.max_nesting_level = 512

in /etc/php/7.2/fpm/php.ini add this: xdebug.remote_port=9999 exit;

in atom:

that got me going. hopefully i'll be the last person to spend all day on this mess.

jayzhou215 commented 6 years ago

Just fix the problem, talk about why I have this error.

After I installed the xdebug, I didn't setting up my xdebug in php.ini. I found that the atom debuger listen to port 9000, so I restarted my local server to 127.0.0.1:9000, and thought , aha, It should work. But, I got the error. The error seems tell me that atom cannot bind to the port 9000 (of source, in my case, it was bound by myself for local server...)

after set up my xdebug just follow the readme.md

xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1    # Not safe for production servers
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
cchamplin commented 6 years ago

The default in 0.3.0 should be back to binding to all addresses on the port.