I am trying to implement my first Rest API using Laravel.
I am running Debian on a Virtual Box machine on a Windows host. The network card of the VM is configured to "Host-only adapter".
I am able to reach the phpmyadmin instance on the machine using http://ip-of-the-vm/phpmyadmin. But when I try to reach the Laravel appliance on http://ip-of-the-vm:8000 it does not work. I think the port could be the problem.
Does anybody have a suggestion for how to solve this?
The problem was that laravel was only reachable over localhost. You have to start the server using
php artisan serve --host 0.0.0.0 where 0.0.0.0 should be replaced with the ip of the server.
You can optionally define a port if you want by using
php artisan serve --host 0.0.0.0 --port 80 for example.
Related
Yii2 and php the code is deployed to docker, Mongodb The database is deployed at windows environment。 And the connection succeeds。examine windows vlan and the service is started 127.0.0.1:27017)
Is there any way to solve this problem?
Use host server's private ip (192.168.?.? / 172.?.?.?) instead of "127.0.0.1" in the php file in docker.
You can also use php 's getenv() function
docker run --add-host=host-server:${HOSTIP} ...
If it doesn't work, try to edit Mongodb's config file.
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
This is related to docker, not yii or mongodb.
You use 127.0.0.1, This is refrenced to code own docker container and can not see mongodb container. You can use overlay network in same range ip.
for example, this is your docker container in same network:
mongodb-container
backend-container
your addressing to mongodb should use mongodb-container:27017 or ip address of container.
Also, you can publish mongodb port to public, 0.0.0.0:27017 and just allow to your back-end app to access your mongodb ip and port with firewall.
This is depend on your system architect in networking and server configuration.
I also encountered the same problem as the subject, but my mongo is in a docker container.
The official server has been running for a while without any problems, but it started throwing exceptions last night, and restarting MongoDB is fine.
Here is the command line:
docker restart mongo
We have a PHP app which we installed on Azure VM. It works fine locally and accessible.
The server at 104.xxx.xx.xx is taking too long to respond.
We have used WAMP Server to host it and all looks fine. We are however not able to access it over the public ip of the server.
We have tried a few things without any result.
First of all, you can check if the port is listening with CMD comamnds netstat -anbo. If the port is listening on external address 0.0.0.0 then you can check if the firewall inside the Azure VM or NSG associated with the Azure VM NIC or subnet blocking it.
Navigated to the virtual machine --- networking ---inbound port rules to find the related NSG rules on the Azure portal.
You also can telnet the VM public IP address and port from the on-premise machine to validate the networking connection.
I need one help.I am unable to connect access mongodb remotely from localhost of my system using PHP. I am running mongoDB in ubuntu server using this 10.10.5.80 and i am trying to connect from my system localhost for that i used the following code.
$con=new MongoClient("mongodb://10.10.5.80:27017");
But unable to connect.I have already checked the whether that post is listening or not and its running in my ubuntu server.When i am pushing all my code to that particular ip(10.10.5.80) its working fine.Here i need to connect that remote mongoDB server from localhost.Please help me to resolve this issue.
Please check following things in order to diagnose the issue:
Try connecting remote mongodb server from mongo shell from your local machine:
mongo --host 10.10.5.80 --port 27017
If step 1 fails, try to check if the remote port 27017 is accessible from you local machine
telnet 10.10.5.80 27017
If both 1 and 2 fail, it confirms that the remote mongo server is not accessible from you server.
Make sure your remote mongodb server is not bind to only 127.0.0.1(default), if that's the case you need to comment out the line in mongod.conf and restart the service.
If your mongodb on hosted on cloud, then make sure there is a security group rule that allows your local machine to access the remote host.
You can check mongodb logs/ mogostats if your requests from local machine adding up connections
I am developing a symfony project on my local machine, I wish to test it on my mobile via IP (both machines connected to wifi network). how do I access port 8000 (symfony's default port) on my mobile phone?
I already know about accessing localhost via IP of the serving device, but I want to access the port too(8000) which I cannot fetch from my devices!
Thanks for all the help
As answered to another Question this might be solved when adding the parameter 0.0.0.0:8000 to let Symfony not only respond to local requests but also accept requests from other devices.
The call then should look something like this:
php bin/console server:run 0.0.0.0:8000
Same way you accessing it from your local machine but using it's IP address e.g.:
http://192.168.1.2:8000
where 192.168.1.2 is your machine IP address in local network (check it using ipconfig command - on Windows or ifconfig on Linux/Mac OS X). Please make sure your firewalls (on local machine and on router) does not block this (8000) port.
UPD: By the way, as far as I remember, Symfony's default port is 8080, not 8000. Please check it carefully.
I've looked for a solution in the web, but I've not found a solution yet.
I need to access to my Laravel 5 app from my iPhone, but I'm in develop, so I don't want to publish my app on a web server.
If you have a link to follow, that you assure it works, It's perfect for me.
Thank you!
If you're not bound to using Apache or nginx for some special reason and this is for development purposes only, you could serve the application using the PHP built-in server and artisan. It's by far the easiest thing to setup, and will only require you to run one command in the Laravel application directory:
php artisan serve --host 0.0.0.0
The default port it will be listening to will be 8000 to avoid any conflicts, so you can now access the application from your phone via the IP address of your computer:
http://192.168.1.101:8000
If you want to listen to another port (for example the default HTTP port of 80) you can pass that as a parameter, just make sure no other server is running on that port. So if you run this instead:
php artisan serve --host 0.0.0.0 --port 80
You can now access your application with just the IP address:
http://192.168.1.101
Its simple, first you have to run the server
php artisan serve --host 0.0.0.0
Then you need to know what`s your IP address, run this command to get IP:
In windows:
ipconfig
In Linux:
hostname -I
For example, my IP is: 192.168.1.68
Once you get your IP, then you have to go to this address on your mobile. Like:
192.168.1.68:8000
And that's it.
There are so many ways to do this.
Access your web via IP address from your iPhone, e.g. http://192.168.1.100/laravel
If your iPhone is jailbroken, you can edit iPhone's /etc/hosts file, the access your website via domain, e.g. laravel.com 192.168.1.100
Upload laravel app to web server and config it a test domain, e.g. dev.domain.com, or dev.domain.com:8080
If you can config your WiFi router, you can give your computer a "port forwarding" or set "DMZ"
Upload your website, and config "IP forbidden" roles, e.g. for Apache, edit your laravel's .htaccess file:
Deny from all
Allow from 180.159.251.175
You can use Laravel Homestead, an official pre-packaged Vagrant "box" to develop your project and access your local website from multiple machines within the same private network.
Here you can find more information about homestead and how to use it:
http://laravel.com/docs/5.0/homestead
And here a sample Vagrant private network setup:
http://docs.vagrantup.com/v2/networking/private_network.html
If you are having trouble using the accepted answers method, and you get page not found or similar errors, this is likely due to your firewall settings.
If
php artisan serve --host 0.0.0.0
doesn't seem to work.
Try php artisan serve --host 0.0.0.0 --port 80.
And access just using your IP address. For instance:
http://192.168.1.101