Meteor build with dynamic server address


Hello, I try to build a Meteor app I develop. The app consists from:

  • server
  • Android client
  • iOS client

The server is going to be deployed on different small servers (Raspberry Pi) in local networks, and it is not going to be hosted on public hosting.

1.How can I build the meteor bundle without specify --server? I don’t know the server at build time. When I execute meteor build builds I get:
Supply the server hostname and port in the --server option for mobile app builds.

2.How can I specify the server address on clients at runtime? I tried using _meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL and __meteor_runtime_config__.ROOT_URL, but seems they don’t do any effect on the default DDP connection.

Ultimately I would like to run SSDP advertiser server on the server and SSDP discovery on the clients using Then do DDP.connect() to the discovered service. Any help or hint is more than welcome.



Question 1:
It is no possible directly i think, but what you can do is locate the server address to localhost, then you have no connection to the server.

Question 2:
You can not change the root url or the default ddp connection i think, but you can use DDP.connect() on client for access to the server.



Thanks. What are for these meteor_runtime_config_.DDP_DEFAULT_CONNECTION_URL and meteor_runtime_config.ROOT_URL? At which state they could be set in runtime? And could they be set runtime at all?

I really can’t believe there aren’t more questions like this. What if we want to use Meteor not on a public host, but to distribute the bundle and users run it on their servers. What is the proper Meteor way to do that?


The problem is Meteor init this variables on startup, one solution is you can work with a bash startup script.

The script set all varibles and then run meteor for the server.

For the mobile clients you can work with ddp.connect or you change the server url in the minified js file, but i’m not sure that this works.

Do you have more informations about your project?


Hi norBu,
lets separate the two things - client and server:

1.On server we create a bat/sh script where we set things like:

export MONGO_URL=mongodb://localhost:27017/something
export ROOT_URL=http://local-network-ip

Question - why is ROOT_URL needed on server anyway? Just to handle CORS?

2.On the client:

  • we need to put something in the --server param when when we make the bundle, because otherwise we are not allowed to proceed. So we make a build with meteor build <location> --server=http://my_dummy_server
  • however we can’t just search and substitute “http://my_dummy_server” with the real server IP on the minified JS, because we don’t know that IP at that moment. Please remember - the server is going to be shipped as a regular node app (bundle) and users will run it on their own servers on local network. Mobile apps will be shipped as Cordova apps on stores and they need to figure out the server IP runtime on app launch.

Question - how can I execute some client JS code BEFORE Meteor.startup(function() {}); function executes? I want to discover the server IP via bonjour/mdns/ssdp/whatever, then find and overwrite the needed variable that is used in the default DDP.connect() function (which I think is __meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL). Any ideas how to do it?



at the moment i don’t have time to make example, but i have two ideas.

  1. The User can set on his local router dns a domain, then you can config a default server address.

  2. The users are not need hot code push while your server is bundled so is a modify of the files not possible. So you can use ddp.connect() to access the data from the local server. Why you don’t want use ddp.connect()?


To be honest, I’m not really familiar what is the difference between default DDP connection and additional connections created with DDP.connect(). Is all the meteor goodness going to work with it out of the box? I mean stuff like reactive collections, user login, etc.

Setting domain is an option, but I would love to not going at that road. I would like to provide easy and seamless installed app, without network kung-fu in order to work. I’m kinda disappointed that Meteor isn’t providing a proper way for this really trivial use case. I never thought this is going to be such a problem. :frowning:


With ddp.connection() do you have all the Meteor magic from client and server. The only difference is you don’t have hot code push.

See the docs for more infos about ddp.connect

best norBu


Hi @mishoboss ,

Have you come up with a clean solution to connect to different servers? I’m facing the same problem.

Looking forward to your reply (on anyone else’s if there are new tips), sincerely,



Hi @flogo,
unfortunately not. To be honest, I dropped Meteor and I built my solution using FeathersJS. Meteor is really nice & powerful tool when you want to build something quick and host it easily, but it fails miserably when you want something more custom. Of course, this is just my personal opinion.


Thanks for your feedback, Misho :slight_smile: Fortunately my customer lets me develop one app per server, so that’s the solution!