ERR_CONNECTION_REFUSED at axios.get() execution

Hello,

I’ve been researching for days every possible solution but I still get the same error when trying to connect to my MongoDB database using axios.get("http://localhost:4000/api/v1/quality"); in my front-end reactjs app. I get the following error in console. I tried every possible port but I get this error every time:

I started the MongoDB server with brew services start mongodb-community@7.0. Status started. No issues there, tho during installation I had to create a new folder on the desktop to store the db., and I changed the dbPath in the mongod.conf file.

The MongoDB Compass app is running and a connection is created on mongodb://localhost:27017. When I access this link in Chrome, it outputs It looks like you are trying to access MongoDB over HTTP on the native driver port.

I tried re-installing everything: MongoDB, my app, the db, etc. Can someone help me fix this ERR_CONNECTION_REFUSED error and fetch my data from the db?

To connect to mongodb you will need to use a driver, mongodb does not have an http api.

For example:

This is the connection string.

Why are you using http against the database ?

We’ve already been over the point you need to use a driver to access the database and no http api is provided.

Take a look at some of the quick starts and tutorials at the Developer Center

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.