I'm trying to access my Laravel project APIs on my mobile phone. Since both my machine and mobile are under the same Wi-Fi, I'm trying to run the php artisan serve on my LAN like so.
php artisan serve --host=192.167.1.101
This runs fine and I do connect, but no API calls to the server go through. It doesn't even log a call.
This seems to work just fine when I use my mobile internet and hotspot my machine. But this is not convenient as my mobile internet is very limited.
I've boiled it down to be an issue with the LAN. But that's as far as my knowledge goes.
Is there anything I need to enable?
Thanks.
After months, I've finally found the solution. Turns out my Firewall was set to not trust my WiFi network (which I use for my LAN).
As soon as I added it to the trusted list, everything works!
Related
I'm at a complete loss as to why this is failing, so get ready for the novel describing exactly what I'm trying to accomplish and what I've tested so far.
Goal:
I'm building a webpage on my GoDaddy hosting account that I want to connect to my locally hosted Radarr server's API via PHP cURL.
I want to use PHP so I can obfuscate the IP, port, and APIKey on the client side. Plus, some of Radarr's API calls I would like to use cannot be run via query string.
Problem:
No matter what I try, I am getting nothing but the following error:
Failed to connect to <MY PUBLIC IP ADDRESS> port <PORT NUMBER>: Connection refused
(And yes, this is the publicly opened port, not the internal port on the server.)
Setup:
I installed Radarr on a FreeNAS (11.3-U5) jail hosted in my home. This is working beautifully.
I setup the FreeNAS jail with a dedicated IP address instead of allowing it to NAT internally, just to make sure it doesn't cause any issues.
I configured port forwarding on my router to allow external traffic into the Radarr server. This is working. Note: Xfinity is my ISP, but I purchased the router separately.
I have a GoDaddy hosting account where I've written a webpage to tie into Radarr's API on my local network. Currently, the webpage is also working beautifully to query data from the API, BUT it's connecting to Radarr via $.getJSON with JavaScript and jQuery.
(Before anyone says it, yes, I know GoDaddy hosting isn't the best option, but it's the one I'm using.)
Testing:
I swear I've tested EVERYTHING and I don't know why this is failing.
This IS working through the JavaScript/jQuery solution, meaning the Radarr server is up and running, the port is properly forwarded through my router, and GoDaddy's hosting isn't blocking the connection.
I CAN access the raw JSON API response in the browser simply by entering the full API URL call.
And while I'd say I am versed in PHP, I'm certainly no expert, so I even tried pulling a generic PHP cURL script from another StackOverflow post, changing the URL to mine, and running that with no luck. Note: The original script DID work to connect to another external API though.
Then I tried Postman, which worked, and I used Postman to create a PHP script, but that script failed.
All of the functional testing done on my local network was done using my publicly facing IP address. However, just to be certain, I also tried reaching the API through the browser off my network, and that worked just fine.
In a desperate attempt, I also reached out to GoDaddy support to see if they had any ideas. They went as far as creating a test PHP cURL script in the same hosting directory and had it simply pull Google's homepage. That worked just fine.
After GoDaddy was unable to help, I setup a free hosting account and free subdomain on AwardSpace, uploaded the script, and that failed too.
In digging into the Connection Refused error, someone suggested just trying to ping the IP through PHP. I attempted this, but it returned 100% packet loss. Also, I logged into my router and watched the incoming connections as I tested. Using the jQuery solution, I saw the incoming connection and it worked great. Using the PHP solution, it didn't register anything inbound.
Lastly, I have confirmed that the publicly opened port on my router is in the list of blocked port by Xfinity. However, since I can access the server externally through the browser and via the jQuery script, that can't be the issue.
There seem to be many, many, many articles online about the general Connection Refused error, but I haven't found a solution to my problem from any of them.
Does anyone have any suggestions?
I've written a webapp in php, which works as a standalone app, but needs to get/post new data from time to time to an API (written by a different company, for desktop software) on localhost. When connecting, it would be from a webpage/browser open on that machine.
So far I've attempted to send curl requests, basically using the generated postman curl code, and it's returning false. I'm thinking it's because it can't connect to the localhost server, possibly because it's blocked from the internet.
I've been researching for a few days, but want a solution that doesn't involve me creating security vulnerabilities in the computers I am trying to connect to, by opening them directly to the internet, and if there is a way to send requests to localhost without installing more software on them I would be partial to that kind of setup.
Does this make sense? I hope someone has some experience or wisdom in this area that could at least nudge me in the right direction.
The localhost is always the computer where you refer to that host. You can't connect to the localhost from your webapp, because the localhost hostname for that app is the computer which runs it.
You have to open a tunnel from you computer to the internet where you webapp can communicate with it.
You can use ngrok to do that, for example
I am a complete beginner at web developing. I want to try accessing my web server through another device from another network. Likewise, I have managed to access it from the same Wi-Fi using my iPhone using my local IP, it ran similar to what I imagined but when I tried to connect to the server using another Wi-Fi it will not show anything. I think I have tried port forwarding, but I couldn't find an exact solution for that. Thank you in advance.
Explanation of what any of the fillable slots means is very appreciated
I have been trying to make things work for a while now but I did not succeed. I also have done a lot of research, in vain. I really hope that someone is able to help me find the root cause of that issue:
I am trying to connect to my localhost:8000 from another computer (which actually is an arduino ethernet but that doesn't make a difference I guess) by using an ip address. I set the ip address manually in network settings (192.168.1.5).
funny enough, the connection from the external device to 192.168.1.5:80 (which is the normal apache server) works, hence the problem cannot be IP-based.
However, the connection to the php built in webserver running on localhost:8000 does not work. I am trying to access it with '192.168.1.5:8000' obviously - I guess this can not be the mistake?
Now I am wondering what the cause of the problem is. Is anything preventing the connection to port 8000 or does the php built in webserver not respond to the manually given ip? Why does the apache respond to that IP though?
Thanks so much for any hint!!
Steffen
The built in server is, by default, only available on localhost. You have to provide a address wildcard mask, if you want to access it over the local network.
$ php -S 0.0.0.0:8000
However, please be aware of the security implications. If your machine is connected to the internet directly, automatic port scanners will find it sooner or later and may take advantage of security problems.
An address mask of 0.255.255.255 will do fine for 10...* networks, and 0.0.255.255 will do fine for 192.168.. networks.
I need to test my website on multiple browsers (mainly ie8 & ie7), but bare in mind this website uses PHP which is running on a local server (using WAMP stack). The website is not on-line yet.
Furthermore, the website is interactive so simple screenshots will not do.
Can someone please help me find a tool that helps me test my site keeping in mind of the 2 things mentioned above. Thanks!
The best method is to put it online and use BrowserStack. It's an online service that creates a virtual machine, forwarded to your computer by Flash. The website will be slow, but still interactive. It's free for 30 minutes, or free for 3 months if you make an account via this Microsoft website. It's then quite cheap for that kind of service.
If you really want to test on your local server, you can use Internet Explorer 9, tap the F12 button to bring the developper tools, and then select a browser mode, like IE 7.
If you're using WAMP you can simply launch the desired browser and then go to
localhost/your_website_folder
Of course you must know where your localhost refers to. In WAMP it should be
C:\wamp\www
by default. So to access your website, you need to put it in C:\wamp\www\your_website_folder.
http://www.browserstack.com/
This is a web based virtual machine that tests pretty much every browser.
It can also set up a tunnel to test on your local host.
You get a short amount of time for free - just make sure you log out when you finish testing to stop it eating into your free trial period further