Configure Maven with Proxy Settings

I am well familiar with Maven concept and working in it for atleast a couple of years.With that confidence and experience i set it up on a Windows Machine. Actually it was my first try on a Windows machine.

After downloading and setting it up in System and Eclipse IDE , i found a weird issue which i never faced.

I could not be able to run “mvn install” or “mvn build” . The execution failed in the first level itself saying “Connection refused”.
“Connection refused ” what the hell is that ??

After a bit googling and some hints from my collegues i understood that some how my system is protected with a firewall or some network  access restirctions. That is the reason why maven can not be able to connect to a remote server.

In order to get rid of this situvation we need to use “Proxy Settings” with maven as well as Eclipse.

Yea , understood the problem space and got the solution . Its time to work it out and get it done.

I assume that you already installed and set up JAVA_HOME,MAVEN_HOME in Environment Variables. If not please follow these to install and configure Maven. Okies..Game begins..

Go to your Maven installation folder and you can see a “conf” folder as a first level directory. In that “conf” folder , you can see
a xml file named “settings.xml”.

Open the “settings.xml” file and locate the part where it specifies “<proxies> or “<proxy>”. It looks like

<!-- proxy
 | Specification for one proxy, to be used in
 connecting to the network.

By default this proxy setting is commented. Just un comment it and specify all these details.If you dont know your <host> and <port> , then just take your Internet Explorer –> Internet Options –> Connections –> LAN Settings.

Make the changes in “settings.xml” and save it.Yes..its done in Maven command prompt. Now you can be able to run maven commands  successfully in command prompt with “mvn”.

It does not mean that Maven is working with Eclipse IDE. We should do some thing here in Eclipse IDE to set Maven up.

I assume that you opened Eclipse IDE. Go to Windows –> Preferences –> Maven and select “User Settings”.

You can see a prompt asking for some “User Settings” file. Most probably such a file does not exists. The default location is “.m2” folder. Dont worry , you can create a new xml file with  the following settings.

<settings xmlns=""

Once the file is created then just Browse that file and set it in “User Settings” ( The path is mentioned above). Yea..Its done..

Now you can run Maven commands both in Command Promt as well as in Eclipse IDE. There will not be any connection refused issues any more.

Enjoy coding.. Enjoy Maven..


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: