How to access locally running Meteor + React project from phone?

Apologies if this is a stupid question or I’m not using the right terminology, but I’ve tried searching for this with multiple different wordings and haven’t come across an answer.

A bit of context: I’ve been building a static website with React, and me and my team are now moving it to Meteor so that we can build out a backend.

I can get the site up and running at http://localhost:3000, just like with React, with the meteor command in the terminal, but I can’t figure out how to get it to show up on my phone.

I really liked the way React also hosted the app at a local IP address and told you that IP address in the terminal after running npm start, and I was wondering if there’s any way to get similar functionality with Meteor.

I’d love to have hot reloading on both my phone and my computer while I’m working on the frontend of the project.

Thanks in advance! :smile:

I did a little more digging (specifically, I ran meteor help run), and it looks like the --mobile-server argument might be what I’m looking for. However, I’m not sure how to get it running…

It says: “Defaults to your local IP and the port that the Meteor binds to” which I thought meant I could just run meteor run --mobile-server but then it tells me that --mobile-server needs a value.

Am I heading in the right direction?

Hello, try this with your ip

meteor run --mobile-server http://192.168.1.120:3000
1 Like

Hm, it starts running with that and says “=> App running at: http://localhost:3000/” but when I navigate to that address on my phone (same WiFi network) it just gives me “Unable to connect”

I also tried with the one that I think React used before (it was saved in my mobile browser history): 192.168.86.58:3000, and it didn’t work either :frowning_face:

Thanks for your reply!

You just want to view the website on your phone?

It should be as simple as http://[insert your local ip address here]:3000
e.g. if your ip address is 192.168.0.50 then http://192.168.0.50:3000

That should work on both computer and phone (as long as the phone is on the same network)

Make sure you can see it on the computer first. If you can, then try the phone. If you can’t then there is probably a network issue.

1 Like

Ah thank you, your reply made me realize what I was doing wrong. I didn’t know what my local IP was! :man_facepalming:

I guess “localhost” is basically a “domain name” for my local IP address?

Anyway, thank you!

(If anyone finds this thread in the future, on a Mac, you can go to System Preferences > Network and it tells you your local IP address under Status)

No worries. Glad I could help. You are correct regarding localhost domain.

Also, while you are in the terminal launching meteor, you could also use ifconfig | grep inet to find your IP address.

1 Like

Also for a really nice way to open a tunnel to your local machine, check out https://ngrok.io

2 Likes

That’s genius!

Thanks :slight_smile:

1 Like