Home > database >  Using a http://192.168 address for a local laravel rest API
Using a http://192.168 address for a local laravel rest API

Time:09-21

Im upgrading from laravel 7 to laravel 8 and Im trying to make a http request to a laravel API hosted locally. If I use http://localhost or http://127.0.0.1, the requests give a response. But if I use a http://192.168.x.x address, I get an error Error: connect ECONNREFUSED. How do I use http://192.168.x.x ?

https://i.stack.imgur.com/98Z1r.png

CodePudding user response:

Access Laravel project over a network using IP

1- Identify your IP Address

on windows ipconfig

on linux ifconfig

2-Run your project php artisan serve --host=192.168.1.10 --port=8000

3-Access your project via browser (on remote)

http://192.168.1.10:8000

Possible Issues:

If your firewall is enabled, remote system might me blocked access. – for this, you can either disable firewall completey on your local system – or, enable certain port In linux to allow a port

ufw status ufw enable 8000

  • Related