[Solved] Running both web and mobile apps at the same time (locally)

I’m developing both web and mobile app from the same repo, using the same code base and resources for both.

The problem is that I can run web server OR cordova app one at a time, but I can’t run them both at the same time, so that mobile app connects to that local server (http://localhost:3000) instead if its own (bundled one).

When one is already started, starting the second one throws Unexpected mongo exit code 100 error, meaning that the mongo connection is already in use (by the other one).

I’ve already tried

meteor run ios-device --mobile-server=http://localhost:3000

but no luck.

So, it’s only for development/debugging, not for deployment/production.

Is that even possible or I have to separate and run them from respective dirs?

why don’t you use a dedicated mongodb instance on your local development computer and point your MONGO_URL at that?

I use that set up on my development machine for all my meteor development work and find it much better for a lot of other requirements, too.

Why would you want this? The Cordova local server is also updates constantly by meteor?

Hi Miro,

So I had a similar requirement. The solution for me was to use micro-services.

  • 1 Meteor App for the browser application
  • 1 Meteor App for the mobile application
  • Shared code symlinked into both apps

So in the end, you would run two meteor servers on two different ports.

This was easier for me than packing all that code into one app. Actually, I have 4 meteor apps using the shared code with different front-ends like this.

May not be the best solution for you, but think about it.

Thank you all guys!

The solution was actually very simple and @serkandurusoy pointed me in the right direction.

I was worried that db connection error is just one in many, happen to occur first and others might appear when the connection sorts out, but fortunately I was wrong :wink:

All I needed to do is setting the env variable and it started to work!

MONGO_URL=mongodb://localhost:3000/myapp meteor run ios-device

(Assuming, of course, that the web app is already running :wink: )

I was really not looking forward to separating the project into web and mobile parts, so this saved me from that :slight_smile:

BTW, these apps will not use MongoDB in the end, but Postgres via Apollo, so I didn’t want to have to install MongoDB and manage it just for development.

1 Like

I think you can do something like MONGO_URL="" so that meteor does not start a mongo instance at all.