Meteor ios app get wrong server on code refresh

Using command

meteor run ios-device --mobile-server

works fine, but when i do an update to the code of my app while this command is running, it correctly refresh code in the application but pointing to a wrong data source, returning this error on the app:

Failed to load resource: Could not connect to the server. http://localhost:3000/sockjs/info?cb=fpbx3y94_g

But in meteor run i said that server is !!

Why this happened?? What’s wrong with my application config?

did you try setting ROOT_URL ?

To give a little more context to @pahans question:

Because subsequent updates delivered through Hot Code Push replace the initially bundled index.html with a freshly generated one, the server should also be configured with the right connection URL.

Using meteor deploy takes care of setting these values automatically, so there is no need to specify anything in that case. But when deploying on your own server, you have to make sure to set at least the ROOT_URL environment variable (DDP_DEFAULT_CONNECTION_URL defaults to the same value). For Meteor Up for example, you can configure this in mup.json.

Hi, i just try launching my app like: ROOT_URL= meteor run ios-device --mobile-server= but i have the same problem…

Here is my steps:

  • I start my server like: ROOT_URL= meteor
  • Start my apps (installed using the ROOT_URL=xxxx meteor run ios-device etc…)
  • Edit code
  • Same problem on apps when refreshing

You don’t have to set the ROOT_URL when you use meteor run, that is what the --mobile-server option is for. And you only need to specify it if the default IP address detection doesn’t give you the right address, so usually only when you run the server on a different machine.

Maybe I’m misunderstanding what is going on, but I thought you were running the app on a separate server, not as part of meteor run. Is that not the case?

Yes, you are right. I need to start a server and i have a lot of clients like browsers and apps that have to link this server. I have a local network connection, and i need to update clients via wireless everytime i update my code bacause i have a lot of clients in this network… everything works fine on iOS/ Android and browsers clients if i not edit my code… but for example if i change a color of a button in html code meteor refresh the clients and i have the error only on apps (browsers works correctly)

But how are you starting your server? Are you using meteor build and running on Node yourself, or using Meteor Up?

What I was trying to say is that you need to set ROOT_URL on your server process.

Hi, i’m starting meteor server using:

ROOT_URL= meteor

then i start my application on iOS (I install it befare on iPad using ROOT_URL= meteor run ios-device --mobile-server= )

On server and client I’m not using deployed version or meteor up, i’m using directly meteor command to start webserver and mongodb…

Is this the problem? I need a deployed version of my app for sync work correctly? Why i can’ t use directly meteor command? Is this a problem for performance?

No, running it using ROOT_URL= meteor should be fine.

As I mentioned, you don’t need to set ROOT_URL for meteor run ios-device, specifying --mobile-server should be enough.

I do see two different IP addresses here, and Is that a typo? Or what are you trying to accomplish there?

i just try with --mobile-server without using ROOT_URL but i have the same problem.
The correct ip is i have type wrong when i put .10 sorry…

Here is my first try: meteor run ios-device --mobile-server

then i do ROOT_URL= meteor

Same problem…

I just do another try with meteor app’ to-do simple’ on another machine:

  1. meteor run ios-device --mobile-server and stop app and command on my mac.
  2. Restart server on mac using ROOT_URL= meteor and restart app on iPad in the same network
  3. Edit project code on my mac
  4. Get same error on ipad: Failed to load resource: Could not connect to the server. http://localhost:3000/sockjs/info?cb=8ufrj68b7t


I have to put this code in my app:

if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
process.env.MOBILE_DDP_URL = ‘’;
process.env.MOBILE_ROOT_URL = ‘’;

I’m glad you got it working, but an easier solution that would give you the same effect is to specify --mobile-server when running the server, that should set these environment variables internally.

You are right…

now i use:

meteor run ios-device --mobile-server
meteor --mobile-server

Works very good!

Thank you