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

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

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x