Socket port not accessible
See original GitHub issueI have BrowserSync running in a docker container. Docker maps a random external port to the exposed internal port.
For BrowserSync, this means that the websocket cannot be reached when using the UI. The script used by the UI generates a URL which points at port
setting, but the script is being run in a browser outside of the container context.
Example: port 3000 is mapped to 49300 and port 3001 (UI) is mapped to 49301. I visit http://site.dev:49301/ in my browser, the UI page loads. The UI scripts tries to connect to site.dev:3000, which fails.
I’m not really sure how to go about fixing this, as by design, the software running inside a container doesn’t know which port the host has exposed.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:3
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Python socket on Windows 7 is not accessible from another ...
Whatever I do, the socket seems to be accessible from the local machine but not from elsewhere on the network. I've got the...
Read more >docker: Error response from daemon: Ports are not available ...
I have tried with the latest version of my channel (Stable or Edge); I have uploaded Diagnostics; Diagnostics ID: Expected behavior. Actual behavior....
Read more >Solved - An attempt was made to access a socket in a way ...
If you're seeing an error that says "An attempt was made to access a socket in a way forbidden by its access permissions."...
Read more >TCP/IP port exhaustion troubleshooting - Windows Client
TCP and UDP protocols work based on port numbers used for establishing ... a connection will fail as there are no more ports...
Read more >Server Service or Port Not Accessible - IONOS Help
For example, if the web server on port 80 (HTTP) is no longer available, or is basically unavailable, it is probably due to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As far as the internal/external port issue, I’ve actually just started seeing this issue after upgrading to the latest version of browsersync. Everything used to work correctly since Browsersync would use the location hostname + port from the browser to create the socket.io path, but now after b2fa3372b806499bf4cd4b978273b740f11fa87d it seems now will use #{location.hostname}:#{port} which isn’t correct in my case. I use NGINX in another docker container to proxy to the Browsersync docker container so the ports that Browsersync aren’t going to be the external one.
Basically, if Browsersync reverts back to using location.host instead of location.hostname I think it should work.
Although a very old issue I spent a considerable amount of time trying to see the issue and trying potential fixes.
I think I narrowed it down to different commits around work done on #625.
And probably other related ones.
I believe that when the issue above was done something was not properly thought and some other things were wrongly replaced. First when you set a proxy browser-sync is setting it to “snippet” mode and I believe that’s wrong.
Also, you can set proxy with:
Which apparently is intended to also proxy the webservice, but then on some other places it feels as the same setting is used in the opposite way.
While I think I could submit a PR I am also not sure if I will cover or be able to test all use cases (like the one on #625) and there seems to be little activity in terms of PRs in the module, so I tried to come up with a workaround.
While probably not great (still neat and useful) this is what I did and it does work.
I am setting the local client javascript back to what it was back then like what’s mentioned above.
The proxyRes function might not be needed but I am also documenting it and it’s an useful way of allowing POSTs (forms) to work.
It’s possible that by doing this the intended fix for #625 is lost, so if you have other WS going through the proxy, this might not be the best way of doing it or you might need to do something further.